Solve grid shortest-path and tree DP | TikTok Interview Question