Math, asked by Bunty356, 11 months ago

Iterate through list integers doubling the value of b each time one of integer is equal to it at current time

Answers

Answered by DreamBoy786
0

Answer:

Step-by-step explanation:

Iterate through a container and get a list of added strings in some order. ... should not require counting all elements in a double-linked list just to ensure that it contains at least one. ... Don't worry about memory allocation — vector will not allocate just one element each time. ... In general pair<int,int> is a pair of integer values.

Answered by tora17
0

Answer:

  • Find all the subsequences of length. While doing so compute the sum and of the two elements and check if it is equal to k. If ye, print Yes, else keep searching. This is a brute Force approach.

  • Sort the array in non-decreasing order. Then start traversing the array from its right end. Say we have the sorted array, {3,5,7,10} and we want the sum to be 17. We will start from element 10, index=3, let's denote the index with 'j'. Then include the current element and compute required_sum= sum - current_element. After that, we can perform a binary or ternary search in array[0- (j-1)] to find if there is an element whose value is equal to the required_sum. If we find such an element, we can break as we have found a subsequence of length 2 whose sum is the given sum. If we don't find any such element, then decrease the index of j and repeat the above-mentioned steps for resulting subarray of length= length-1 i.e. by excluding the element at index 3 in this case.
Similar questions