Barraiser interview question

Leet code question of dynamic programming