Tech Mahindra Interview Question

two sum from leetcode medium