@sunny Keep count of longest repeated element in diff i.e 2 so count =2 so ap of 2 elem with diff 2 .
On Fri, Jul 8, 2011 at 1:03 AM, sunny agrawal <sunny816.i...@gmail.com>wrote: > @rajiv > Fails i think > think for 10 12 24 26 > diff is 2 12 2 > so do you want to say there is an AP pf 3 elements with d = 2, i can't see > any :P > your solution fails because there can be many APs in the array with the > same value of d and you will finish up by combining all those APs > > > On Fri, Jul 8, 2011 at 12:55 AM, rajeev bharshetty > <rajeevr...@gmail.com>wrote: > >> >> Check the differences between the adjacent elements and store the >> differenecs in diff[i] array >> then scan through the array . >> then keep a count for all the repeated diff elements ,the sequence of >> indexes with max count is the solution . >> >> >> >> >> On Thu, Jul 7, 2011 at 11:43 PM, Piyush Sinha >> <ecstasy.piy...@gmail.com>wrote: >> >>> Given an array of integers A, give an algorithm to find the longest >>> Arithmetic progression in it, i.e find a sequence i1 < i2 < … < ik, >>> such that >>> >>> A[i1], A[i2], …, A[ik] forms an arithmetic progression, and k is the >>> largest possible. >>> >>> The sequence S1, S2, …, Sk is called an arithmetic progression if >>> >>> Sj+1 – Sj is a constant. >>> >>> -- >>> *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. >>> >>> >> -- >> 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. >> > > > > -- > Sunny Aggrawal > B-Tech IV year,CSI > Indian Institute Of Technology,Roorkee > > -- > 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.