Pregunta de entrevista de Snap

Dynamic programming and recursion question