Pregunta de entrevista de Amadeus

Easy Algorithm problem and optimization