这道题其实和最小的K个数是一样的做法了~
https://blog.nowcoder.net/n/203599c0c609451c99bd4d1ee4d8b239

class Solution {
public:
    int partition(vector<int>&arr,int l,int r)
    {
        int x = arr[l];
        while( l < r )
        {
            while(l < r && arr[r] <= x) { r--;}
            arr[l] = arr[r];
            while(l < r && arr[l] > x) { l++;}
            arr[r] = arr[l];
        }
        arr[l] = x;
        return l;
    }
    int findKth(vector<int> a, int n, int K) {
        // write code here
        vector<int> ans;
        int l = 0;
        int r = n-1;
        int mid = partition(a,l,r);
        while(mid != K-1)
        {
            if(mid > K-1)
            {
                r = mid-1;
                mid = partition(a,l,r);
            }
            else{
                l = mid+1;
                mid = partition(a,l,r);
            }
        }

        return a[K-1];
    }
};