Can u use the same logic u use for a+b=k for difference..
because, here if you increase a or decrease b in both case
difference will increase.. ? correct me if i am wrong.



On Jun 7, 2:39 pm, Piyush Sinha <[email protected]> wrote:
> Whats the problem in using two pointers one pointing the lower index while
> the other pointing the upper index??
>
>
>
>
>
>
>
>
>
> On Tue, Jun 7, 2011 at 2:57 PM, ross <[email protected]> wrote:
> > 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
> > bin search) when you
> > encounter a[i]. methods like hash consume space.
>
> > Is an O(n) solution with O(1) extraspace possible?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> *Piyush Sinha*
> *IIIT, Allahabad*
> *+91-8792136657*
> *+91-7483122727*
> *https://www.facebook.com/profile.php?id=100000655377926*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to