--- from: http://rosettacode.org/wiki/Longest_increasing_subsequence