What did you learn? The "complement lookup" pattern: instead of checking all pairs, for each element check if its complement exists.
Add to map after checking. This prevents using the same element twice.
Store value-to-index because you need to return indices, not values. This pattern generalizes: three-sum uses two-sum as a subroutine, four-sum uses three-sum, and so on.