|
|
| Perl-Sensitive Sunglasses | |
| PerlMonks |
Re: Puzzle: Longest Increasing Sequenceby gaal (Parson) |
| on Apr 16, 2006 at 08:25 UTC ( #543624=note: print w/ replies, xml ) | Need Help?? |
|
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.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||