Shortest Unsorted Continuous Subarray

Medium

📝 Description

Find shortest subarray that if sorted would make entire array sorted

Input Format

Space-separated array elements

Output Format

Length of shortest subarray

Constraints

1 ≤ nums.length ≤ 10^4

🔍 Sample Input

2 6 4 8 10 9 15
            

✅ Sample Output

5
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run