LeetCode--Sort Colors(颜色排序)Python

题目:python 给定一个长度为n的数组,数组中包含三种颜色的球。将相同颜色的球链接排列。返回从新排列后的数组。其中0、一、2分别表明一个颜色数组 解题思路:code 统计数组中0、一、2分别出现的次数。根据次数从新对数组进行赋值。io 代码(Python):class class Solution(object): def sortColors(self, nums):
相关文章
相关标签/搜索