Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Longest Arithmetic Subsequence
Bookmark
Brute Force
Hash Map DP
Input
Example 1 (diff=3)
Example 2
Example 3
Custom
nums
=
[3, 6, 9, 12]
nums
3
0
6
1
9
2
12
3
gap = -
length = -
maxLen = -
nums
3
0
6
1
9
2
12
3
gap = -
length = -
maxLen = -
nums
3
0
6
1
9
2
12
3
i
j
run so far
3
6
gap = 3
length = 2
maxLen = 2
nums
3
0
6
1
9
2
12
3
i
j
run so far
3
6
9
12
gap = 3
length = 4
maxLen = 4
nums
3
0
6
1
9
2
12
3
i
j
run so far
3
9
gap = 6
length = 2
maxLen = 4
nums
3
0
6
1
9
2
12
3
i
j
run so far
3
12
gap = 9
length = 2
maxLen = 4
nums
3
0
6
1
9
2
12
3
i
j
run so far
3
12
gap = 9
length = 2
maxLen = 4
nums
3
0
6
1
9
2
12
3
i
j
run so far
6
9
12
gap = 3
length = 3
maxLen = 4
nums
3
0
6
1
9
2
12
3
i
j
run so far
6
12
gap = 6
length = 2
maxLen = 4
nums
3
0
6
1
9
2
12
3
i
j
run so far
9
12
gap = 3
length = 2
maxLen = 4
nums
3
0
6
1
9
2
12
3
gap = 3
length = 2
maxLen = 4
algo
master
.
io
Step:
Longest run of numbers with a constant gap in [3, 6, 9, 12]?
0 / 34
Input
Example 1 (diff=3)
Example 2
Example 3
Custom
nums
=
[3, 6, 9, 12]
0 / 34
algo
master
.
io
Step:
Longest run of numbers with a constant gap in [3, 6, 9, 12]?