标签:tor sort public cto for ++ void pre vector
class Solution {
public:
void sortColors(vector<int>& nums) {
for (int i = 0, j = 0, k = nums.size() - 1; i <= k;) {
if (nums[i] == 0) swap(nums[i++], nums[j++]);
else if (nums[i] == 2) swap(nums[i], nums[k--]);
else i++;
}
}
};
标签:tor sort public cto for ++ void pre vector
原文地址:https://www.cnblogs.com/clown9804/p/13300421.html