Solved finding longest non-decreasing sequence with dynamic programming with O(n2) time complexity and O(n) space complexity