Re: [algogeeks] Re: difference x

2010-12-23 Thread snehal jain
bhupendra's   solution  is right..

On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote:

 make  another array(B) from (A) with all elements negated
 now find one element from B and one from A  whose sum is x or -x. This can
 ofcourse be done in O(n).

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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.



Re: [algogeeks] Re: difference x

2010-12-23 Thread Nikhil Agarwal
Divya and saurabh please post your working solution different from that of
Bhupen's.

On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote:

 make  another array(B) from (A) with all elements negated
 now find one element from B and one from A  whose sum is x or -x. This can
 ofcourse be done in O(n).

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Thanks  Regards
Nikhil Agarwal
Senior Undergraduate
Computer Science  Engineering,
National Institute Of Technology, Durgapur,India
http://tech-nikk.blogspot.com
http://beta.freshersworld.com/communities/nitd

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-23 Thread Amit Jaspal
@ jai nice solution

I think for O(n) solution we will have to use extra array.
Otherwise we will have to do this in O(nlogn).
Correct me if i am wrong.


On Thu, Dec 23, 2010 at 1:04 PM, jai gupta sayhelloto...@gmail.com wrote:

 make  another array(B) from (A) with all elements negated
 now find one element from B and one from A  whose sum is x or -x. This can
 ofcourse be done in O(n).

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Amit Jaspal
Btech IT IIIT- Allahabad

-- 
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.



[algogeeks] Re: difference x

2010-12-22 Thread juver++
There is simple solution of the similar problem: given sorted array, find 
two values which sum up to X.
It can be solved with two pointers, such approach has been discussed on the 
forum some months ago.

Your problem is similar.

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Saurabh Koar
@Snehal:

U r going crazy man.U r blindly picking up problems and throwing them
in this group.It is not a place solving ur homework problems.Plz post
problems which r either tricky so that the members can learn something
or post problems which u cant solve after giving a measurable
effort.Try to use ur minimum intelligence to solve a
problem.Otherwise(as pointed out by Swapnil some days ago) it really
decreases the value of this group.More people will be active if they
see new thought provoking problems.Also, u post problems and don't
clear doubts of the members regarding ur problems.This is also bad
habit.

Hope u will understand.No offence intended.

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread snehal jain
@saurabh

u might be a genius bt for ur kind information this is the group for
learners... this group is a place where people come to learn new tricks, put
their ideas and ask doubts.. so it would have been better if u had put your
response rather than discouraging anyone from asking doubts..
while putting this problem i had the nlogn approach in my mind as pointed by
vivek. but i wanted a better approach O(n) as it exist for the sum problem
where sum=x. so i posted it here.. it does not mean if u know a solution
than the problem is   solved. there is always a chance of optimization which
u can learn only by discussing...
u could simply delete mail if u find it so simple..
and everybody has his own style.. now a days i was solving algorithm
problems from various blogs and sites so i posted all my doubts in one go...

On Wed, Dec 22, 2010 at 7:44 PM, Saurabh Koar saurabhkoar...@gmail.comwrote:

 @Snehal:

 U r going crazy man.U r blindly picking up problems and throwing them
 in this group.It is not a place solving ur homework problems.Plz post
 problems which r either tricky so that the members can learn something
 or post problems which u cant solve after giving a measurable
 effort.Try to use ur minimum intelligence to solve a
 problem.Otherwise(as pointed out by Swapnil some days ago) it really
 decreases the value of this group.More people will be active if they
 see new thought provoking problems.Also, u post problems and don't
 clear doubts of the members regarding ur problems.This is also bad
 habit.

 Hope u will understand.No offence intended.

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Ankur Khurana
@snehal : nothing wrong in what saurabh said. it was just that if you
are posting a question , then you should also post the approach you
have thought.plus you are posting in bulk . so , please whenever you
give a question , also mention your approach. it gives greater
confidence in question to be solved.

On Wed, Dec 22, 2010 at 9:35 PM, snehal jain learner@gmail.com wrote:
 @saurabh

 u might be a genius bt for ur kind information this is the group for
 learners... this group is a place where people come to learn new tricks, put
 their ideas and ask doubts.. so it would have been better if u had put your
 response rather than discouraging anyone from asking doubts..
 while putting this problem i had the nlogn approach in my mind as pointed by
 vivek. but i wanted a better approach O(n) as it exist for the sum problem
 where sum=x. so i posted it here.. it does not mean if u know a solution
 than the problem is   solved. there is always a chance of optimization which
 u can learn only by discussing...
 u could simply delete mail if u find it so simple..
 and everybody has his own style.. now a days i was solving algorithm
 problems from various blogs and sites so i posted all my doubts in one go...

 On Wed, Dec 22, 2010 at 7:44 PM, Saurabh Koar saurabhkoar...@gmail.com
 wrote:

 @Snehal:

 U r going crazy man.U r blindly picking up problems and throwing them
 in this group.It is not a place solving ur homework problems.Plz post
 problems which r either tricky so that the members can learn something
 or post problems which u cant solve after giving a measurable
 effort.Try to use ur minimum intelligence to solve a
 problem.Otherwise(as pointed out by Swapnil some days ago) it really
 decreases the value of this group.More people will be active if they
 see new thought provoking problems.Also, u post problems and don't
 clear doubts of the members regarding ur problems.This is also bad
 habit.

 Hope u will understand.No offence intended.

 --
 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.


 --
 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.


-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread snehal jain
@ankur..

its ok if u r asking for approach.. i ll do it from next tym.. bt posting in
bulk is not an offence.. i bet u dont the solution to all my problems.. some
of them u mite know some of them mite b new for u.. well same here u mite
ask a prob and i mite find it easy.. i posted these problem cz i wanted to
discuss it.. y wud i flood the group with question? ( i dont enjoy dat) i
just posted all my doubts in one go.. as i had finishd many blogs n sites
recently.

On Wed, Dec 22, 2010 at 10:04 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 @snehal : nothing wrong in what saurabh said. it was just that if you
 are posting a question , then you should also post the approach you
 have thought.plus you are posting in bulk . so , please whenever you
 give a question , also mention your approach. it gives greater
 confidence in question to be solved.

 On Wed, Dec 22, 2010 at 9:35 PM, snehal jain learner@gmail.com
 wrote:
  @saurabh
 
  u might be a genius bt for ur kind information this is the group for
  learners... this group is a place where people come to learn new tricks,
 put
  their ideas and ask doubts.. so it would have been better if u had put
 your
  response rather than discouraging anyone from asking doubts..
  while putting this problem i had the nlogn approach in my mind as pointed
 by
  vivek. but i wanted a better approach O(n) as it exist for the sum
 problem
  where sum=x. so i posted it here.. it does not mean if u know a solution
  than the problem is   solved. there is always a chance of optimization
 which
  u can learn only by discussing...
  u could simply delete mail if u find it so simple..
  and everybody has his own style.. now a days i was solving algorithm
  problems from various blogs and sites so i posted all my doubts in one
 go...
 
  On Wed, Dec 22, 2010 at 7:44 PM, Saurabh Koar saurabhkoar...@gmail.com
  wrote:
 
  @Snehal:
 
  U r going crazy man.U r blindly picking up problems and throwing them
  in this group.It is not a place solving ur homework problems.Plz post
  problems which r either tricky so that the members can learn something
  or post problems which u cant solve after giving a measurable
  effort.Try to use ur minimum intelligence to solve a
  problem.Otherwise(as pointed out by Swapnil some days ago) it really
  decreases the value of this group.More people will be active if they
  see new thought provoking problems.Also, u post problems and don't
  clear doubts of the members regarding ur problems.This is also bad
  habit.
 
  Hope u will understand.No offence intended.
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Saurabh Koar
@Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
r very basic.As u solved the looping prob in other thread I think u r
intelligent enough to solve this prob(difference x) easily and also
some other probs posted by u(not all).Some problems posted by u are
really very tricky and I loved them.I jst requested u while posting if
u review the ques carefully it will be helpful.I dint want to hurt
u.If u r I m sorry.Bt still I will request u to post carefully.Lets
finish this.And sorry once again.

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Ankur Khurana
ya i agree , your questions are good though.

On Wed, Dec 22, 2010 at 10:19 PM, snehal jain learner@gmail.com wrote:
 @ankur..

 its ok if u r asking for approach.. i ll do it from next tym.. bt posting in
 bulk is not an offence.. i bet u dont the solution to all my problems.. some
 of them u mite know some of them mite b new for u.. well same here u mite
 ask a prob and i mite find it easy.. i posted these problem cz i wanted to
 discuss it.. y wud i flood the group with question? ( i dont enjoy dat) i
 just posted all my doubts in one go.. as i had finishd many blogs n sites
 recently.

 On Wed, Dec 22, 2010 at 10:04 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 @snehal : nothing wrong in what saurabh said. it was just that if you
 are posting a question , then you should also post the approach you
 have thought.plus you are posting in bulk . so , please whenever you
 give a question , also mention your approach. it gives greater
 confidence in question to be solved.

 On Wed, Dec 22, 2010 at 9:35 PM, snehal jain learner@gmail.com
 wrote:
  @saurabh
 
  u might be a genius bt for ur kind information this is the group for
  learners... this group is a place where people come to learn new tricks,
  put
  their ideas and ask doubts.. so it would have been better if u had put
  your
  response rather than discouraging anyone from asking doubts..
  while putting this problem i had the nlogn approach in my mind as
  pointed by
  vivek. but i wanted a better approach O(n) as it exist for the sum
  problem
  where sum=x. so i posted it here.. it does not mean if u know a solution
  than the problem is   solved. there is always a chance of optimization
  which
  u can learn only by discussing...
  u could simply delete mail if u find it so simple..
  and everybody has his own style.. now a days i was solving algorithm
  problems from various blogs and sites so i posted all my doubts in one
  go...
 
  On Wed, Dec 22, 2010 at 7:44 PM, Saurabh Koar saurabhkoar...@gmail.com
  wrote:
 
  @Snehal:
 
  U r going crazy man.U r blindly picking up problems and throwing them
  in this group.It is not a place solving ur homework problems.Plz post
  problems which r either tricky so that the members can learn something
  or post problems which u cant solve after giving a measurable
  effort.Try to use ur minimum intelligence to solve a
  problem.Otherwise(as pointed out by Swapnil some days ago) it really
  decreases the value of this group.More people will be active if they
  see new thought provoking problems.Also, u post problems and don't
  clear doubts of the members regarding ur problems.This is also bad
  habit.
 
  Hope u will understand.No offence intended.
 
  --
  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.
 
 
  --
  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.
 

 --
 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.


 --
 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.


-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Ankur Khurana
saurabh , asking for a better sol. is not a crime. rest everybody is
intelligent.

On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com wrote:
 @Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
 r very basic.As u solved the looping prob in other thread I think u r
 intelligent enough to solve this prob(difference x) easily and also
 some other probs posted by u(not all).Some problems posted by u are
 really very tricky and I loved them.I jst requested u while posting if
 u review the ques carefully it will be helpful.I dint want to hurt
 u.If u r I m sorry.Bt still I will request u to post carefully.Lets
 finish this.And sorry once again.

 --
 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.



-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread rajat ahuja
nyone like to post solution of ths problem,

On Wed, Dec 22, 2010 at 10:28 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 saurabh , asking for a better sol. is not a crime. rest everybody is
 intelligent.

 On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com
 wrote:
  @Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
  r very basic.As u solved the looping prob in other thread I think u r
  intelligent enough to solve this prob(difference x) easily and also
  some other probs posted by u(not all).Some problems posted by u are
  really very tricky and I loved them.I jst requested u while posting if
  u review the ques carefully it will be helpful.I dint want to hurt
  u.If u r I m sorry.Bt still I will request u to post carefully.Lets
  finish this.And sorry once again.
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread snehal jain
@ saurabh
its fine..
nd can u plz tell ur soln to this prob.. i hv figured out an O(n) solution..
bt b4 dat i wanna knw ur solution..


On Wed, Dec 22, 2010 at 10:31 PM, rajat ahuja catch.rajatah...@gmail.comwrote:

 nyone like to post solution of ths problem,

 On Wed, Dec 22, 2010 at 10:28 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 saurabh , asking for a better sol. is not a crime. rest everybody is
 intelligent.

 On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com
 wrote:
  @Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
  r very basic.As u solved the looping prob in other thread I think u r
  intelligent enough to solve this prob(difference x) easily and also
  some other probs posted by u(not all).Some problems posted by u are
  really very tricky and I loved them.I jst requested u while posting if
  u review the ques carefully it will be helpful.I dint want to hurt
  u.If u r I m sorry.Bt still I will request u to post carefully.Lets
  finish this.And sorry once again.
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread juver++
Please don't use abbreviated words in your posts. Speak in pure English.

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread rajat ahuja
saurabh .. i would like to know your solution
can u please tell me ,, i want to know

On Wed, Dec 22, 2010 at 11:50 PM, juver++ avpostni...@gmail.com wrote:

 Please don't use abbreviated words in your posts. Speak in pure English.

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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.



[algogeeks] Re: difference x

2010-12-22 Thread Aviral Gupta
use hash map.O(n)
or you can use use the binary search for each element
O(nlogn) 

Regards
Aviral
http://coders-stop.blogspot.com

On Dec 22, 3:05 pm, snehal jain learner@gmail.com wrote:
 How will you find the pair from an sorted array whose difference is x

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread bhupendra dubey
send the data set to the hash table
now search for a[i]+x in the table if found for 'k' den a[k] and a[k]+x is
the required pair

complexity:
o(n)(for mapping)+O(n)(for search a[i]+x)=O(n)

@Snehal can i see your solution please.

On Thu, Dec 23, 2010 at 12:11 AM, Aviral Gupta aviral@gmail.com wrote:

 use hash map.O(n)
 or you can use use the binary search for each element
 O(nlogn) 

 Regards
 Aviral
 http://coders-stop.blogspot.com

 On Dec 22, 3:05 pm, snehal jain learner@gmail.com wrote:
  How will you find the pair from an sorted array whose difference is x

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
bhupendra dubey

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread juver++
Your solution needs extra space and it has only *expected* O(n) time. There 
is O(n) inplace solution

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread bhupendra dubey
@juver:thanx  for making me work... please notice this
this also uses the sorted property of the array

 i=0,j=1;
while((i!=n-1) or  j!=n)
{
/*compare difference of a[j] and a[i]*/
if( (a[j]-[a[i]])x )
i++;
else if( (a[j]-a[i])x)
j++;
else
{
/*SOLUTION*/
return;
}
}

regards

complexity:O(n)
On Thu, Dec 23, 2010 at 12:29 AM, juver++ avpostni...@gmail.com wrote:

 Your solution needs extra space and it has only *expected* O(n) time.
 There is O(n) inplace solution

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
bhupendra dubey

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread yq Zhang
@bhupendra
Nice solution!

Yq

On Wed, Dec 22, 2010 at 11:29 AM, bhupendra dubey
bhupendra@gmail.comwrote:

 @juver:thanx  for making me work... please notice this
 this also uses the sorted property of the array

  i=0,j=1;
 while((i!=n-1) or  j!=n)
 {
 /*compare difference of a[j] and a[i]*/
 if( (a[j]-[a[i]])x )
 i++;
 else if( (a[j]-a[i])x)
 j++;
 else
 {
 /*SOLUTION*/
 return;
 }
 }

 regards

 complexity:O(n)

 On Thu, Dec 23, 2010 at 12:29 AM, juver++ avpostni...@gmail.com wrote:

 Your solution needs extra space and it has only *expected* O(n) time.
 There is O(n) inplace solution

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 bhupendra dubey

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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.



[algogeeks] Re: difference x

2010-12-22 Thread Minotauraus
Also a general FYI, please, please, please search before you post.
Seeing the same Qs again and again for regulars isn't very interesting
either.


On Dec 22, 11:29 am, bhupendra dubey bhupendra@gmail.com wrote:
 @juver:thanx  for making me work... please notice this
 this also uses the sorted property of the array

  i=0,j=1;
 while((i!=n-1) or  j!=n)
 {
 /*compare difference of a[j] and a[i]*/
 if( (a[j]-[a[i]])x )
 i++;
 else if( (a[j]-a[i])x)
 j++;
 else
 {
 /*SOLUTION*/
 return;

 }
 }

 regards

 complexity:O(n)

 On Thu, Dec 23, 2010 at 12:29 AM, juver++ avpostni...@gmail.com wrote:
  Your solution needs extra space and it has only *expected* O(n) time.
  There is O(n) inplace solution

  --
  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.comalgogeeks%2bunsubscr...@googlegroups 
  .com
  .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 bhupendra dubey

-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Divya Jain
@ saurabh
and i wanna ur solution to this prob
i know O(nlogn) post ur O(n) solution,.
i hv some idea bt i wanna knw ur ans b4 mine

On 22 December 2010 22:32, Divya Jain sweetdivya@gmail.com wrote:

 its okk


 On 22 December 2010 22:28, Ankur Khurana ankur.kkhur...@gmail.com wrote:

 saurabh , asking for a better sol. is not a crime. rest everybody is
 intelligent.

 On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com
 wrote:
  @Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
  r very basic.As u solved the looping prob in other thread I think u r
  intelligent enough to solve this prob(difference x) easily and also
  some other probs posted by u(not all).Some problems posted by u are
  really very tricky and I loved them.I jst requested u while posting if
  u review the ques carefully it will be helpful.I dint want to hurt
  u.If u r I m sorry.Bt still I will request u to post carefully.Lets
  finish this.And sorry once again.
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread Divya Jain
its okk

On 22 December 2010 22:28, Ankur Khurana ankur.kkhur...@gmail.com wrote:

 saurabh , asking for a better sol. is not a crime. rest everybody is
 intelligent.

 On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com
 wrote:
  @Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
  r very basic.As u solved the looping prob in other thread I think u r
  intelligent enough to solve this prob(difference x) easily and also
  some other probs posted by u(not all).Some problems posted by u are
  really very tricky and I loved them.I jst requested u while posting if
  u review the ques carefully it will be helpful.I dint want to hurt
  u.If u r I m sorry.Bt still I will request u to post carefully.Lets
  finish this.And sorry once again.
 
  --
  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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 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.comalgogeeks%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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.



Re: [algogeeks] Re: difference x

2010-12-22 Thread jai gupta
make  another array(B) from (A) with all elements negated
now find one element from B and one from A  whose sum is x or -x. This can
ofcourse be done in O(n).

-- 
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.