var minEatingSpeed = function(piles, h) {
let l=0,k=Math.max(...piles)
let res=k
while(l<k){
let m=Math.floor((k-l)/2)+l
let time=getTime(m,piles)
if(time<=h){
res=m
k=m
}else{
l=m+1
}
}
return res
}
const getTime=(speed,piles)=>{
let time=0
for(let i of piles){
time+=Math.ceil((i/speed))
}
return time
}
var MovingAverage = function(size) {
this.nums=[]
this.l=size
this.sum=0
};
MovingAverage.prototype.next = function(val) {
this.nums.push(val)
this.sum+=val
if(this.nums.length>this.l){
this.sum-=this.nums.shift()
}
return this.sum/this.nums.length
};
var RecentCounter = function() {
this.opt=[]
};
RecentCounter.prototype.ping = function(t) {
this.opt.push(t)
this.count=0
while(this.opt[0]<t-3000){
this.opt.shift()
}
return this.opt.length
};