Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 124: Maps: Fundamentals
Given an **unsorted** array `nums` and a `target`, return the 0-based indices `[i, j]` (i < j) of the two numbers that add up to `target`. Exactly one solution exists. Example: `twoSumUnsorted([2, 7, 11, 15], 9)` → `[0, 1]`.
+ 2 hidden tests run on Submit.
Store each value-to-index as you scan and look up the complement. O(n) time and space.
Run your code to see results.