题目链接:https://leetcode-cn.com/problems/sort-colors/
题目如下:
class Solution { public: void sortColors(vector<int>& nums) { quicksort(nums,0,nums.size()-1); } void quicksort(vector<int>& nums,int l,int r){ if(l>=r) return; int i=l-1,j=r+1; int target=nums[(i+j)>>1]; while(i<j){ do i++; while(nums[i]<target); do j--; while(nums[j]>target); if(i<j) swap(nums[i],nums[j]); } quicksort(nums,l,j); quicksort(nums,j+1,r); } };