in reply to Longest Increasing Subset

I'm not sure of the rule you are using but this gives the answer you say you want.

johngg@shiraz:~ > perl -Mstrict -Mwarnings -E ' my @arr = ( 2, 6, 5, 7, 4, 3, 9 ); my @sub = shift @arr; push @sub, $arr[ 0 ] > $sub[ -1 ] ? shift @arr : do { shift @arr; () } while @arr; say for @sub;' 2 6 7 9

Just a guess really, perhaps you could explain the rule you are using more clearly. For instance, do you always start with the first item in the list or the smallest? Both the same in this case so I'm not sure.

Cheers,

JohnGG