Skip to content

Commit 88df364

Browse files
committed
Update solution 075 [Python3]
1 parent 7ae4900 commit 88df364

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

solution/075.Sort Colors/Solution.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,17 @@ def sortColors(self, nums):
33
"""
44
:type nums: List[int]
55
:rtype: void Do not return anything, modify nums in-place instead.
6-
"""
6+
"""
7+
p=-1
8+
q=len(nums)
9+
cur=0
10+
while cur < q:
11+
if nums[cur] == 0:
12+
nums[cur],nums[p+1]=nums[p+1],nums[cur]
13+
cur += 1
14+
p += 1
15+
elif nums[cur] == 1:
16+
cur += 1
17+
else:
18+
nums[cur],nums[q-1]=nums[q-1],nums[cur]
19+
q -= 1

0 commit comments

Comments
 (0)