https://www.nowcoder.com/practice/2baf799ea0594abd974d37139de27896?tpId=117&&tqId=37851&rp=1&ru=/ta/job-code-high&qru=/ta/job-code-high/question-ranking
快速排序
class Solution {
public:
void quick_sort(vector<int>& arr,int left,int right){
if (left > right){
return;
}
int i = left;
int j = right;
int pivot = arr[left];
while (i != j){
while (arr[j] >= pivot && j > i){
j --;
}
arr[i] = arr[j];
while(arr[i] <= pivot && i < j){
i++;
}
arr[j] = arr[i];
}
arr[i] = pivot;
quick_sort(arr, left, i -1);
quick_sort(arr, i + 1, right);
}
vector<int> MySort(vector<int>& arr) {
quick_sort(arr, 0, arr.size()-1);
return arr;
}
};