in reply to Puzzle: Longest Increasing Sequence
Isn't this O(n)? Scan the list and maintain the tuple (start index, length) for your best candidate so far, as well as for the subsequence you are looking at now. If you are currently looking at your best candidate, keep incremening both length field as long as the sequence is monotonic. Reset the 'current' tuple or install the 'best' tuple as appropriate.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Puzzle: Longest Increasing Sequence
by BrowserUk (Patriarch) on Apr 16, 2006 at 10:40 UTC | |
Re^2: Puzzle: Longest Increasing Sequence
by jdporter (Paladin) on Apr 16, 2006 at 15:42 UTC | |
by kaif (Friar) on Apr 16, 2006 at 17:10 UTC | |
by gaal (Parson) on Apr 17, 2006 at 05:13 UTC |
In Section
Seekers of Perl Wisdom