HP Inc. interview question

The two sum question on leetcode.