Quicksort 1 - Partition

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/2HD41pYh8cU

    vector<int> quickSort(vector<int> arr) {
        vector<int> left, equal, right;
        for(int i = 0; i < arr.size(); i++){
            if(arr[i] < arr[0]) left.push_back(arr[i]);
            else if(arr[i] > arr[0]) right.push_back(arr[i]);
            else equal.push_back(arr[i]);
        }
        left.insert(left.end(), equal.begin(), equal.end());
        left.insert(left.end(), right.begin(), right.end());
        return left;
    }