Pregunta de entrevista de AppsFlyer

A heap question, and Dynamic Programming