Two Sum
Hard
arrays
objects_maps
algorithms
Description
Given an array of integers (`nums`) and a target sum, return the indices of the two numbers that add up to the target. Assume exactly one solution exists.
Examples
Example:
Input: nums: [2, 7, 11, 15], target: 9
Output: [0, 1]
Explanation: nums[0] + nums[1] = 2 + 7 = 9.
Constraints
- Input is a list of integers.
- Output must be a list of two indices.
- Exactly one solution exists.
Loading...
Test Case 1
Input: [2,7,11,15],9
Output: [0,1]
Test Case 2
Input: [3,2,4],6
Output: [1,2]
Test Case 3
Input: [3,3],6
Output: [0,1]
