Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Two Sum
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given an array of integers and a target sum, return indices of the two numbers that add up to the target.
Sample Input:
[2, 7, 11, 15], 9
Sample Output:
[0, 1]
Hints
Hint 1
Use a hash map to store previously seen numbers and their indices
Hint 2
For each number, check if (target - current number) exists in the map
Hint 3
This approach gives O(n) time complexity
Code Editor
Reset
Run
Save
Loading...