Pregunta de entrevista de vAuto

nothing difficult, basic algorithm questions.