Simple Clean Python


  • 0
    class Solution(object):
        def sortColors(self, nums):
            i = 0
            for _ in range(len(nums)):
                if nums[i] == 0:
                    nums.insert(nums.pop(i), 0)
                    i += 1
                elif nums[i] == 2:
                    nums.append(nums.pop(i))
                else:
                    i += 1

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.