Amazon Interview Question

LeetCode Array-based question solved using DP