Given an array of integers nums and an integer target, return the indices of the two numbers such that they add up to target.
You may assume that each input has exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Input: An integer array nums and an integer target.
Output: An array of two integers — the indices of the two numbers that sum to target.
Input: [2,7,11,15],9
Output: [0,1]
Explanation: Step 1: Create empty map.
Step 2: i=0, val=2, complement=9-2=7. 7 not in map → store {2:0}.
Step 3: i=1, val=7, complement=9-7=2. 2 IS in map at index 0.
Step 4: Return [0,1]. Verify: nums[0]+nums[1] = 2+7 = 9 ✓Input: [3,2,4],6
Output: [1,2]
Explanation: Step 1: i=0, val=3, complement=3. Not in map → store {3:0}.
Step 2: i=1, val=2, complement=4. Not in map → store {3:0, 2:1}.
Step 3: i=2, val=4, complement=2. 2 IS in map at index 1.
Step 4: Return [1,2]. Verify: nums[1]+nums[2] = 2+4 = 6 ✓Input: [3,3],6
Output: [0,1]
Explanation: Step 1: i=0, val=3, complement=3. Not in map → store {3:0}.
Step 2: i=1, val=3, complement=3. 3 IS in map at index 0.
Step 3: Return [0,1]. Verify: nums[0]+nums[1] = 3+3 = 6 ✓2 <= nums.length <= 10^4-10^9 <= nums[i] <= 10^9-10^9 <= target <= 10^9Only one valid answer exists.