Skip to content

Commit d5129cb

Browse files
authored
Merge pull request doocs#85 from ashwek/SortColors
075 Sort colors - Python (Solution2)
2 parents 488ba43 + 2135ff4 commit d5129cb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

solution/075.Sort Colors/Solution2.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution2:
2+
def sortColors(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: void Do not return anything, modify nums in-place instead.
6+
"""
7+
Count = [nums.count(color) for color in range(3)]
8+
9+
color = i = 0
10+
11+
while i < len(nums):
12+
for j in range(Count[color]):
13+
nums[i] = color
14+
i += 1
15+
color += 1

0 commit comments

Comments
 (0)