Domanda di colloquio di Amazon

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