Easy · Arrays
Two sum
Given an integer array nums (not necessarily sorted) and an integer target, return the indices of the two different elements whose values add up to target, in any order; exactly one such pair exists.
Examples
Example 1
[2,7,11,15] → 9Output: [0,1]
Example 2
[3,2,4] → 6Output: [1,2]
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.