Pregunta de entrevista de J.P. Morgan

Java or Python program was given, I had to choose one and debug and optimize it.