Rubrik interview question

Question related to dynamic programming