Find pair with given sum in the array

Given an unsorted array of integers, find the first pair with given sum in it. Return the index for these integers.

Example Solution

When the solution is called with the following input arr = [8, 7, 2, 5, 3, 1], sum = 10, it is expected to return [0, 2]. arr[0] holds the value 8 and arr[2] is 2. 8 + 2 = 10 which is the desired sum value.

Contributed by Murat Sütunç