Dynamic Programming Patterns Leetcode Two