Two Sum

easy#array#hashmap
← Back to Problems

Given an array of numbers, return indices of the two numbers such that they add up to a specific target.

Function Signature

export function twoSum(nums: number[], target: number): number[] { }

Sample Tests

  • Input: [2,7,11,15], target=9
    Expected: [0,1]