Pregunta de entrevista de Aspire Systems

I was told to write the code logic.