Pregunta de entrevista de Staples

Time/Space complexity of the code