Pregunta de entrevista de Anonymous

dynamic programming problem with a twist