Amazon interview question

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