โ† All coding problems

Two sum

MediumHashing

Return the indexes [i, j] (i < j) of the two numbers in nums that add up to target. Exactly one answer exists.

Function
function solve(nums, target)
Example 1
nums = [2,7,11,15]
target = 9
โ†’ [0,1]

Submit also runs 3 hidden tests, including edge cases.

console.log output is shown below