Snowflake interview question

A dynamic programming problem which is level 'hard' on leetcode