Superna interview question

I was asked dynamic programming leetcode medium