Tap here to switch tabs
Problem
Submissions

Problem: Shortest Unsorted Continuous Subarray

med
30 min
Try to solve the Shortest Unsorted Continuous Subarray problem.

Statement

Given an integer array nums, return the length of the shortest contiguous subarray such that sorting only that subarray in nondecreasing order makes the entire array nums sorted in nondecreasing order. If nums is already sorted in nondecreasing order, return 00.

Note: Follow up: can you solve it in O(n)O(n) time complexity?

Constraints:

  • 11 \leq nums.length 104\leq 10^4

  • 105-10^5 \leq nums[i] 105\leq 10^5

Tap here to switch tabs
Problem
Submissions

Problem: Shortest Unsorted Continuous Subarray

med
30 min
Try to solve the Shortest Unsorted Continuous Subarray problem.

Statement

Given an integer array nums, return the length of the shortest contiguous subarray such that sorting only that subarray in nondecreasing order makes the entire array nums sorted in nondecreasing order. If nums is already sorted in nondecreasing order, return 00.

Note: Follow up: can you solve it in O(n)O(n) time complexity?

Constraints:

  • 11 \leq nums.length 104\leq 10^4

  • 105-10^5 \leq nums[i] 105\leq 10^5