Pregunta de entrevista de LogicMonitor

To solve a algorithm problem in java.