We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8dbdc48 commit c676bbaCopy full SHA for c676bba
1 file changed
0581.最短无序连续子数组/0581-最短无序连续子数组.py
@@ -0,0 +1,19 @@
1
+class Solution(object):
2
+ def findUnsortedSubarray(self, nums):
3
+ """
4
+ :type nums: List[int]
5
+ :rtype: int
6
7
+ s = sorted(nums)
8
+ if s == nums:
9
+ return 0
10
+ for i in range(len(s)):
11
+ if s[i] != nums[i]:
12
+ break
13
+ for j in range(len(s) - 1, -1, -1):
14
+ if s[j] != nums[j]:
15
16
+ # print i, j
17
+ # print s, nums
18
+ return len(s) - i - (len(s) - 1 -j)
19
+
0 commit comments