You are viewing a single comment's thread. Return to all comments →
JavaScript
function miniMaxSum(arr) { arr.sort((a, b) => a - b); let result = arr.reduce((sum, num, index) => { if (index < 4) { sum.min += num; } if (index > 0) { sum.max += num; } return sum; }, { min: 0, max: 0}); console.log(result.min + " " + result.max) }
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
JavaScript