You are viewing a single comment's thread. Return to all comments →
Javascript
function maxMin(k: number, arr: number[]): number { let smallest = Number.POSITIVE_INFINITY; const sorted = arr.sort((a,b) => a-b); for (let i=0; i <= sorted.length - k; i++) { smallest = Math.min(smallest, sorted[i + k - 1] - sorted[i]); } return smallest; }
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