You are viewing a single comment's thread. Return to all comments →
C++ solution
vector<int> quickSort(vector<int> arr) { int pivot = arr[0]; int l = arr.size() - 1; swap(arr[0],arr[l]); int i = 0; int j = l-1; while(i<=j) { while(i<=l && arr[i] < pivot) { i++; } while(j>=0 && arr[j] > pivot) { j--; } if (i<j) { swap(arr[i],arr[j]); } } swap(arr[l],arr[i]); return arr; }
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 1 - Partition
You are viewing a single comment's thread. Return to all comments →
C++ solution