Pregunta de entrevista de JPMorganChase

Typicall SD question and as standard coding problem.