Pregunta de entrevista de J.P. Morgan

Question related to solve given problem