Pregunta de entrevista de Stripe

How would I optimize my code