TikTok interview question

4 programming problems including dfs and dp