Cisco interview question

Dynamic programming problem leetcode medium