class Solution {
public:
void swap(int *p, int *q){
int temp = *p;
*p = *q;
*q = temp;
}
void my_qsort(vector<int> &arr, int i, int j){
int size = arr.size();
int start = i, end = j;
int temp = arr[i];
if(i>=j) return;
while(i<j){
while(i<j&&arr[j]<temp){
j--;
}
swap(&arr[i], &arr[j]);
i++;
while(i<j&&arr[i]>temp){
i++;
}
swap(&arr[i], &arr[j]);
j--;
}
my_qsort(arr,start, i-1);
my_qsort(arr,j+1, end);
}
int findKth(vector<int> a, int n, int K) {
int size = a.size();
my_qsort(a, 0,n-1);
return a[K-1];
}
};