On Mar 15, 10:07 am, saurabh gupta <[email protected]> wrote: > while you scan the array > maintain four indices plus two lengths > two indices and a length mark one sub-array - start,end, length > each such sub-array indicates a non-decreasing sequence, > call them S1 and S2. > > while one scans, S2 keeps track of incoming elements (curr sequence) > S1 keeps track of the maximum length (along with indices) so far (prev > sequence) > as one encounters an element which is less than the previous element, > this marks the end of S2, > S1 replaces S2 if len S2 > len S1 else S2 starts afresh from this new > element. > > In the end if len S2 > len S1 answer = S2 > else answer = S1. > > PS: In the beginning and till one encounters a smaller element than the > prev one for the first time, S1 = S2 >
I agree that this is a nice algorthithm that solves the largest non decreasing sequence problem. However, I don't agree that this solves the problem originally posted. Regards, Ralph Boland -- 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.
