Question: You have an array A of size N that is in ascending order. You have been given a value X, your task is to
You have an array A of size N that is in ascending order. You have been given a value X, your task is to find two such indexes [i and j] from the array such that [A[i] + A[j] == X, where i and j are two separate indexes of the array]. You have to show these indexes if you find it otherwise show -1 and -1 a) Array is sorted, you have to design a O(NlgN) b) Array is sorted, you have to design a O(N)
Step by Step Solution
3.37 Rating (172 Votes )
There are 3 Steps involved in it
a Code in Onlogn complexity Let us assume array A of size N and all th... View full answer
Get step-by-step solutions from verified subject matter experts
