Pregunta de entrevista de Keeper Tax

Classic algorithm question but can’t remember exactly what