Pregunta de entrevista de J.P. Morgan

time complexity,space complexity, python lost functions