class Solution {
public:
    void quickSort(vector<int> &input, int left, int right) {
        if (left >= right) {
            return;
        }
        int i = left, j = right;
        int base = input[i];
        while(i < j) {
            while((i < j) && input[j] >= base) {
                j--;
            }
            
            while((i < j) && input[i] <= base) {
                i++;
            }
            if (i < j) {
                swap(input[i], input[j]);
            }
        }
        input[left] = input[i];
        input[i] = base;
        quickSort(input, left, i - 1);
        quickSort(input, i + 1, right);
    }
    
    vector<int> GetLeastNumbers_Solution(vector<int> input, int k) {
        int len = input.size();
        
        quickSort(input, 0, len - 1);
        input.resize(k);
        return input;
        /*
        vector<int>ret;
        for (int i = 0; i < k; i++) {
            ret.push_back(input[i]);
        }
        
        return ret;
        */
        
    }
};