Genesys interview question

Leetcode question in dynamic programming