Skip to content

Commit 7f4e4fa

Browse files
authored
Added 075 SortColors Solution2.py
1 parent a1a7740 commit 7f4e4fa

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)