标签:int swa swap code begin == 分类 amp end
1 class Solution 2 { 3 public: 4 void sortColors(vector<int>& nums) 5 { 6 int n = nums.size(); 7 int begin = -1; 8 int end = n; 9 int i = 0; 10 while(i < end) 11 { 12 if(nums[i] == 0) swap(nums[++begin],nums[i++]); 13 else if(nums[i] == 1) i++; 14 else swap(nums[--end],nums[i]); 15 } 16 } 17 };
//三路快排模板
标签:int swa swap code begin == 分类 amp end
原文地址:https://www.cnblogs.com/yuhong1103/p/12600475.html