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

30:00

Two Sum
easy
Topics
Companies

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

Example 1:
Input: {"nums":[2,7,11,15],"target":9}
Output: [0,1]
Constraints:
  • 2≤nums.length≤1042 \leq \text{nums.length} \leq 10^4

  • −109≤nums[i]≤109-10^9 \leq \text{nums}[i] \leq 10^9

  • −109≤target≤109-10^9 \leq \text{target} \leq 10^9

  • Only one valid answer exists.

Input
arr ={"nums":[2,7,11,15],"target":9}
nums (Target: 9)2071112153
HashMap

Empty

Variables
No variables to display
DepthFunction Call
1twoSum(nums=[4], target=9)
0/8