class Solution(object):
def findUnsortedSubarray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
left, right = 0, -1
new_nums = sorted(nums)
for i in range(len(nums)):
if nums[i] != new_nums[i]:
left = i
break
for i in range(len(nums)):
if nums[i] != new_nums[i]:
right = i
return right - left + 1
leetcode 581
最新推荐文章于 2024-11-18 22:29:24 发布