mirror of
https://github.com/aykhans/leet-code-problems.git
synced 2025-04-21 05:03:33 +00:00
Added sort_colors
This commit is contained in:
parent
5f40879d9a
commit
5bc406a851
@ -125,3 +125,14 @@ class AcceptedMedium:
|
|||||||
if matrix[c][i] != 0:
|
if matrix[c][i] != 0:
|
||||||
matrix[c][i] = 0
|
matrix[c][i] = 0
|
||||||
dont_replace.append([c, i])
|
dont_replace.append([c, i])
|
||||||
|
|
||||||
|
def sort_colors(self, nums: List[int]) -> None:
|
||||||
|
"""
|
||||||
|
Link: https://leetcode.com/problems/sort-colors/description/
|
||||||
|
Runtime: 52 ms
|
||||||
|
"""
|
||||||
|
nums_len = len(nums)
|
||||||
|
for i in range(nums_len):
|
||||||
|
for j in range(nums_len-i-1):
|
||||||
|
if nums[j] > nums[j+1]:
|
||||||
|
nums[j], nums[j+1] = nums[j+1], nums[j]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user