Amazon Interview Question

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