Pregunta de entrevista de DRW

Difficult programming assignment.