Pergunta de entrevista da empresa Snap

Dynamic programming and recursion question