Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Two Sum
Bookmark
Brute Force
Hash Map (One Pass)
Input
Example 1
Example 2
Example 3
Custom
nums
=
[2, 7, 11, 15]
,
target
=
9
target =
9
pairs checked =
0
nums
2
7
11
15
0
1
2
3
target =
9
pairs checked =
0
nums
2
7
11
15
0
1
2
3
target =
9
pairs checked =
0
nums
2
7
11
15
0
1
2
3
j
i
fix
i = 0
, sweep
j = 1..3
target =
9
pairs checked =
1
nums
2
7
11
15
0
1
2
3
j
i
2
+
7
=
9
=
target 9
target =
9
pairs checked =
1
nums
2
7
11
15
0
1
2
3
j
i
return [0, 1]
2 + 7 = 9
algo
master
.
io
Step:
Find two numbers that add up to target = 9
0 / 3
Input
Example 1
Example 2
Example 3
Custom
nums
=
[2, 7, 11, 15]
,
target
=
9
0 / 3
algo
master
.
io
Step:
Find two numbers that add up to target = 9