Pregunta de entrevista de TikTok

Medium graph/DP problem with recursion