import java.util.*;
public class Solution {
public int findKth(int[] a, int n, int K) {
// write code here
for(int gap = a.length/2;gap>0;gap/=2){
for(int i = gap ; i<a.length;i++){
int j = i;
int temp = a[j];
if(a[j]>a[j-gap]){
while(j-gap>=0&&temp>a[j-gap]){
a[j]=a[j-gap];
j-=gap;
}
a[j]=temp;
}
}
}
int count = 0 ;
for(int h =0;h<a.length;h++){
if(a[h]!=K){
count++;
}
if(count == K){
return a[h];
}
}
return 0;
}
} 
京公网安备 11010502036488号