In an array of integers, find two integers whose sum is 10 without looping.
Sigiloso
Algorithm: hasArrayTwoCandidates (A[ ], ar_size, sum) 1) Sort the array in increasing order. 2) Initialize two index variables to find the candidate elements in the sorted array. (a) Initialize first to the leftmost index: l = 0 (b) Initialize second the rightmost index: r = ar_size-1 3) Loop while l 16 => decrement r. Now r = 10 A[l] + A[r] ( -8 + 10) increment l. Now l = 1 A[l] + A[r] ( 1 + 10) increment l. Now l = 2 A[l] + A[r] ( 4 + 10) increment l. Now l = 3 A[l] + A[r] ( 6 + 10) == 16 => Found candidates (return 1)