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.
functionmaxMin(k,arr){// sort - lowest to highestarr.sort((a,b)=>a-b);// calculate unfairness of "first chunk" of size kletminUnfairness=arr[k-1]-arr[0];for(leti=1;i+k-1<arr.length;i++){// calculate unfairness in "next chunk" of size kconstunfairness=arr[i+k-1]-arr[i];if(unfairness<minUnfairness){minUnfairness=unfairness;}}returnminUnfairness;}
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 →
JS