Skip to content

Commit c676bba

Browse files
committed
2019-12-19
1 parent 8dbdc48 commit c676bba

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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+
break
16+
# print i, j
17+
# print s, nums
18+
return len(s) - i - (len(s) - 1 -j)
19+

0 commit comments

Comments
 (0)