Abbott interview question

Leetcode medium question (Dynamic Programming)