Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Maximum Gap
Bookmark
Sorting
Bucket Sort
Radix Sort
Input
Standard
Large Gap
Custom
nums
=
[3, 6, 9, 1]
INPUT ARRAY
3
6
9
1
sort, then take the largest adjacent difference
INPUT ARRAY
3
6
9
1
sort, then take the largest adjacent difference
SORTED ARRAY
1
3
6
9
sorting puts every pair of neighbours next to each other
SORTED ARRAY
1
3
6
9
2
LARGEST GAP SO FAR
2
gap =
2
, best =
2
SORTED ARRAY
1
3
6
9
3
LARGEST GAP SO FAR
3
gap =
3
, best =
3
SORTED ARRAY
1
3
6
9
3
LARGEST GAP SO FAR
3
gap =
3
, best =
3
SORTED ARRAY
1
3
6
9
LARGEST GAP SO FAR
3
maximum gap = 3
algo
master
.
io
Step:
Sort the array, then the answer is the largest adjacent difference
0 / 5
Input
Standard
Large Gap
Custom
nums
=
[3, 6, 9, 1]
0 / 5
algo
master
.
io
Step:
Sort the array, then the answer is the largest adjacent difference