Amazon interview question

LeetCode Array-based question solved using DP