leetcode75. Sort Colors

xiaoxiao2021-02-28  69

http://blog.csdn.net/linhuanmars/article/details/24286349

class Solution(object):     def sortColors(self, nums):         """         :type nums: List[int]         :rtype: void Do not return anything, modify nums in-place instead.         """         i = j = 0         for k in xrange(len(nums)):             v = nums[k]             nums[k] = 2             if v < 2:                 nums[j] = 1                 j += 1             if v == 0:                 nums[i] = 0                 i += 1

转载请注明原文地址: https://www.6miu.com/read-43055.html

最新回复(0)