Two sum
mediumLists20 XP
Exactly one pair of numbers in nums adds up to target. Return their positions [i, j] with i < j. Can you do it in one pass with a dictionary?
Examples
- Input: nums = [2, 7, 11, 15], target = 9Output: [0, 1]
- Input: nums = [3, 2, 4], target = 6Output: [1, 2]
Examples use JSON: true/false/null are True/False/None in Python.