Given an array of integers arr and an integer target, return the indices of the two numbers in arr that sum to target. Each input has at most one valid pair, and you may not use the same element twice. Return null when no such pair exists.
Input
arr: an array of integers
target: the target sum
Output
A two-element array [i, j] of indices with i < j such that arr[i] + arr[j] == target, or null if no pair exists.
Examples
Example 1
Inputarr = [7, 2, 11, 15], target = 9
Output[0, 1]
Example 2
Inputarr = [1, 2, 3], target = 7
Outputnull
Constraints
0 <= arr.length
Solve in O(n) time using a hash map.