Pregunta de entrevista de Tickertape

How would you solve this problem