Shortest Unsorted Continuous Subarray

Given an integer array nums, find a continuous subarray which, if sorted in non-decreasing order, would make the entire array sorted in non-decreasing order. Return the length of the shortest such subarray.

Constraints

  • 1 <= nums.length <= 10000
  • -100000 <= nums[i] <= 100000
Saving… · 2 lines
class Solution:
def shortestUnsortedContinuousSubarray(self, nums: List[int]) -> int:
Console

Click Run to execute sample tests.