Pregunta de entrevista de Bloomberg

A coding question related to stack.