Skip to main content

Two Sum Problem

Easy • Array • Hash Table

Points: 100
Success Rate: 47.3%
Weather API Integration Apple Laptop Close up laptop

Problem Statement

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

Input Format

nums = [2,7,11,15], target = 9

Output Format

[0,1]

Constraints

  • 2 ≤ nums.length ≤ 10⁴
  • -10⁹ ≤ nums[i] ≤ 10⁹
  • -10⁹ ≤ target ≤ 10⁹

Sample Input/Output

Input: nums = [2,7,11,15], target = 13
Output: [0,2]
Input: nums = [3,2,4], target = 6
Output: [1,2]
Solution.java
Code editor workspace
Status: Ready
Code on computer screen Runtime: 2ms
Code interface preview Test Cases: 0/3
Code editor interface Runtime: 0ms
Software development Memory: 0MB

Analysis Dashboard

Your coding journey insights

Data analytics dashboard
12
Problems Solved
Car dashboard
2h 34m
Total Time
Cryptocurrency market analysis
89%
Success Rate
28
Total Attempts

Problem Performance

Problem Status Time Attempts Action
Two Sum Solved 12m 34s 3 View
Valid Palindrome Solved 8m 21s 1 View
Merge Intervals Attempted 45m 12s 5 View

Two Sum Problem

Easy • Array • Hash Table

Points: 100
Success Rate: 47.3%
Weather API Integration Apple Laptop Close up laptop

Problem Statement

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

Input Format

nums = [2,7,11,15], target = 9

Output Format

[0,1]

Constraints

  • 2 ≤ nums.length ≤ 10⁴
  • -10⁹ ≤ nums[i] ≤ 10⁹
  • -10⁹ ≤ target ≤ 10⁹

Sample Input/Output

Input: nums = [2,7,11,15], target = 13
Output: [0,2]
Input: nums = [3,2,4], target = 6
Output: [1,2]
Solution.java
Code editor workspace
Status: Ready
Code on computer screen Runtime: 2ms
Code interface preview Test Cases: 0/3
Code editor interface Runtime: 0ms
Software development Memory: 0MB

Analysis Dashboard

Your coding journey insights

Data analytics dashboard
12
Problems Solved
Car dashboard
2h 34m
Total Time
Cryptocurrency market analysis
89%
Success Rate
28
Total Attempts

Problem Performance

Problem Status Time Attempts Action
Two Sum Solved 12m 34s 3 View
Valid Palindrome Solved 8m 21s 1 View
Merge Intervals Attempted 45m 12s 5 View