var KthLargest = function(k, nums) {
this.k = k
this.arr = []
for(let i=0;i<nums.length;i++){
this.add(nums[i])
}
};
KthLargest.prototype.add = function(val) {
let sign = true
if(!this.arr.length) {
this.arr.push(val)
} else {
let i = 0
while(i<this.arr.length){
if(val<this.arr[i]){
this.arr.splice(i,0,val)
sign = false
break
}
}
if(sign){
this.arr.push(val)
}
if(this.arr.length>this.k){
this.arr.shift()
}
}
return this.arr[0]
};
快排超时!