We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
function maxMin(k, arr) {
arr.sort((a,b)=>a-b);
let l = arr.length, u = arr[l-1] - arr[l-k];
for(let i = 0;i<=(arr.length-k);i++){
let t = arr[i+(k-1)] - arr[i];
u = t <= u ? t: u;
}
return u;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Max Min
You are viewing a single comment's thread. Return to all comments →
//JavaScript Code
}