Dynamic Programming Patterns Leetcode Contest Solution