class Solution {
public:
void sortColors(vector<int>& nums) {
int p[3]={};
for(auto it:nums)
{
++p[it];
}
int i=0;
for(int j=0;j<3;++j)
{
for(;p[j];--p[j],++i)
{
nums[i]=j;
}
}
return ;
}
};
leetcode - 75. Sort Colors
猜你喜欢
转载自blog.csdn.net/weixin_41938758/article/details/89075778
今日推荐
周排行