Pregunta de entrevista de Amazon

Two sum question, they asked for optimised code and for 2-3 logics