Dynamic Programming Pattern Leetcode Javascript Questions