Pregunta de entrevista de BMAT

Time and space complexity of the solution