← Challenges

Two Sum Indices

Write solve(nums, target) that returns the indices [i, j] (i < j) of the two numbers in nums that add up to target. Assume exactly one solution exists.

Examples

  • solve([2,7,11,15], 9)[0,1]
  • solve([3,2,4], 6)[1,2]