@bhupendra Nice solution! Yq
On Wed, Dec 22, 2010 at 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.com<algogeeks%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<algogeeks%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.