Approach hintTry it first, then revealHide
Scan once and store each value's index in a hash map; before inserting nums[i], check whether target - nums[i] is already present. O(n).
Scan once and store each value's index in a hash map; before inserting nums[i], check whether target - nums[i] is already present. O(n).