Pregunta de entrevista de Wells Fargo

Try to edit the given code for better performance