LIS dp solution O(n^2)