TikTok Interview Question

Similar to Longest Increasing Path in Matrix problem