TikTok Interview Question

Medium graph/DP problem with recursion