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.
- Mini-Max Sum
- Discussions
Mini-Max Sum
Mini-Max Sum
Sort by
recency
|
843 Discussions
|
Please Login in order to post a comment
newarr = sorted(arr, reverse=False) print(int(sum(newarr)-newarr[4]), int(sum(newarr)-newarr[0]))
Sort the array, once sorted, min = sum of first 4 elements and max = sum of last 4 elements
Javascript solution:
function miniMaxSum(arr) { const sum = arr.reduce((accumulator, currentValue) => { return accumulator + currentValue },0);
}
SIMPLE JAVA8 CODING SOLUTION