TikTok interview question

Similar to Longest Increasing Path in Matrix problem