take one pointer to start n another to the end say a n b
now if
a +b > X
shift b towards left n so on




On Fri, Jun 18, 2010 at 9:03 AM, sharad kumar <aryansmit3...@gmail.com>wrote:

> @arun:find out the difference  x-arr[i] for all i=0..n hash it ...next
> search for a number with difference .u can get it in O(n)....
>
> On Fri, Jun 18, 2010 at 8:05 AM, Arunkumar Sreenivasan <
> thegame.a...@gmail.com> wrote:
>
>> Hi,
>>    You are given a set of numbers and another number 'x'. You have to find
>> if there exists any two numbers, whose sum is equal to 'x'. I have done this
>> is o(n)log n. Need a more optimized solution.
>>
>> regards,
>> Arun kumar S
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> yezhu malai vaasa venkataramana Govinda Govinda
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Thanking You
Ashish Mishra

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

Reply via email to