MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / Solution

Class Solution

Array/SortColors.py:55–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54"""
55class Solution(object):
56 def sortColors(self, nums):
57 """
58 :type nums: List[int]
59 :rtype: void Do not return anything, modify nums in-place instead.
60 """
61
62 index = 0
63 times = 0
64 length = len(nums)
65
66 for i in range(length):
67 if nums[index] == 0:
68 x = nums.pop(index)
69 nums.insert(0, x)
70 index += 1
71 elif nums[index] == 2:
72 x = nums.pop(index)
73 nums.append(x)
74 else:
75 index += 1

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected