Dynamic Programming Pattern Leetcode Solutions Python