Leetcode 2d Dynamic Programming