// Complete the miniMaxSum function below.
function miniMaxSum(arr) {
let min = Number.MAX_SAFE_INTEGER
let max = Number.MIN_SAFE_INTEGER
let sum = 0
arr.forEach(n => {
if (n < min) min = n
if (n > max) max = n
sum += n
})
process.stdout.write(`${sum - max} ${sum - min}`)
}
Mini-Max Sum
November 19, 2019 • ☕️ 1 min read
algorithm/hackerrank