Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Shortest Unsorted Continuous Subarray
Bookmark
Sorting
Two-Pass Max/Min
Input
Input 1
Input 2
Input 3
Custom
nums
=
[2, 6, 4, 8, 10, 9, 15]
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
compare each cell with its sorted position
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
nums[0] = 2
matches — still in place
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
nums[1] out of place
→ left = 1
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
nums[6] = 15
matches — still in place
nums
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
nums[5] out of place
→ right = 5
nums
length =
5
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
unsorted, length 5
length = 5 - 1 + 1 =
5
nums
length =
5
2
0
6
1
4
2
8
3
10
4
9
5
15
6
sorted
2
4
6
8
9
10
15
unsorted, length 5
length =
5
algo
master
.
io
Step:
Sort a copy, then compare with the original to find where they differ.
0 / 7
Input
Input 1
Input 2
Input 3
Custom
nums
=
[2, 6, 4, 8, 10, 9, 15]
0 / 7
algo
master
.
io
Step:
Sort a copy, then compare with the original to find where they differ.