You are viewing a single comment's thread. Return to all comments →
function luckBalance(k, contests) { const important = contests .filter((a) => a[1] === 1) .sort((x, y) => y[0] - x[0]) .reduce((sum, a, i) => (i < k ? sum + a[0] : sum - a[0]), 0); const unimportant = contests .filter((a) => a[1] === 0) .reduce((sum, a) => sum + a[0], 0); return important + unimportant; }
Seems like cookies are disabled on this browser, please enable them to open this website
Luck Balance
You are viewing a single comment's thread. Return to all comments →
JavaScript Solution