Do u want to output all the pairs or just 2 integers??
On 6/12/11, p2pnode wrote:
> Problem:
>
> Given an integer 'k' and an sorted array A (can consist of both +ve/-
> ve nos), output 2 integers from A such that a-b=k.
> PS:
> nlogn solution would be to check for the occurence of k-a[i] (using
>
Problem:
Given an integer 'k' and an sorted array A (can consist of both +ve/-
ve nos), output 2 integers from A such that a-b=k.
PS:
nlogn solution would be to check for the occurence of k-a[i] (using
binary search) when you encounter a[i]. methods like hash consume
space.
Is an O(n) solution wi