• Find Sum of all possible pair where i != j and put into sum_array
  • find min and max element of sum_array which is eventually out answer
  • Please See code below:

function miniMaxSum(arr) {
var min=0,max=0,sum_array=[];
for (var i = 0; i < arr.length; i++) {
var sum = 0;
for (var j = 0; j < arr.length; j++) {
if ( i != j ) {
sum += arr[j];
}
}
sum_array[i] = sum;
}

min = sum_array[1],max=sum_array[1];
for (var i = 0; i < sum_array.length; i++) {
if(sum_array[i] > max) {
max = sum_array[i];
}
if(sum_array[i] < max && sum_array[i] < min) {
min = sum_array[i];
}
}

process.stdout.write(min + “ “ +max);
}

--

--