Description
Given an integer array nums, find the shortest continuous subarray that, when sorted, results in the whole array being sorted.
Examples
Input:
nums = [2,6,4,8,10,9,15]Output:
5Explanation:
Sort [6,4,8,10,9].
Input:
nums = [1,2,3,4]Output:
0Explanation:
Edge case returning zero.
Input:
nums = [1]Output:
0Explanation:
Edge case returning zero.
Constraints
- •
1 ≤ nums.length ≤ 10⁴