Pregunta de entrevista de Mars

Technical interview was based on an example problem