@Amit Jaspal....The algo given by me works for the given case..check it....
On 5/20/11, Anurag Bhatia <abhati...@gmail.com> wrote: > Just need some clarification; sorry I joined the thread late. What are we > trying maximize? A[j] -A[i] such that i<j? or j-i such that A[i]<A[j]? > > --Anurag > > On Fri, May 20, 2011 at 12:34 AM, Kunal Patil <kp101...@gmail.com> wrote: >> >> @ Piyush: Excellent Solution...It appears both Correct and O(n)...Good >> work !![?] >> >> Just a minor correction in your algo.[?] >> >> while(B[i]<C[j]) >> j++; >> must also check for J's bound as: >> while ( j < ( sizeof(A)/sizeof(A[0]) ) && B[i]<C[j] ) >> j++; >> Or it will crash when J goes out of bound and we try to reference C[j]. >> >> Nywayz..thnx for the solution and algo !! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@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 algogeeks@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. > -- *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 algogeeks@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.
<<363.gif>>
<<360.gif>>