2Sum
Clarification
The inputs are an integer array nums and an integer target, return the indices of two numbers that add up to target.
Clarifying questions I would ask:
- Are numbers sorted? (Usually no)
- Can there be negative numbers? (Yes)
- Will there be an integer overflow?
- Can I use the same element twice?
- Exactly one solution guaranteed? (Usually yes)
- What should I return if there is no valid answer?
3/16/26About 4 min
