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 <[email protected]>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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
