Amazon interview question

Two sum problem from leetcode