Python version of Longest Increasing Subsequence algorithm