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 

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

1 Expert Approved Answer
Step: 1 Unlock

a Code in Onlogn complexity Let us assume array A of size N and all th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!