Pregunta de entrevista de IMC Trading

Basic Algo question. Maybe Medium difficulty on Hackerrank?