Mini-Max Sum

Sort by

recency

|

384 Discussions

|

  • + 0 comments
    s=arr.sort()
    mi=sum(arr[1:])
    ma=sum(arr[:-1])
    print(ma,end=" ")
    print(mi)
    
  • + 0 comments

    !/bin/python3

    import math import os import random import re import sys

    #

    Complete the 'miniMaxSum' function below.

    #

    The function accepts INTEGER_ARRAY arr as parameter.

    #

    def miniMaxSum(arr): # Write your code here total_sum=sum(arr) min_sum=total_sum-max(arr) max_sum=total_sum-min(arr) print(min_sum,max_sum)

    if name == 'main':

    arr = list(map(int, input().rstrip().split()))
    
    miniMaxSum(arr)
    
  • + 0 comments

    c++20

    void miniMaxSum(vector<int> arr) {
    
    size_t min = numeric_limits<size_t>::max();
    size_t max = numeric_limits<size_t>::min();
    size_t total = 0;
    
    for(size_t value : arr){
        total += value;
        
        if(value < min){
            min = value;
        }
        if(value > max){
            max = value;
        }
        
    }
    
    std::cout << total-max << " " << total-min << std::endl;
    }
    
  • + 0 comments
    res = []
        for idx,records in enumerate(arr):
            summed = 0
            for idxs,records in enumerate(arr):
                if idx==idxs:
                    continue
                else:
                    summed+=records
            res.append(summed)
        res.sort()
        print(res[0],res[len(res)-1])
    
  • + 0 comments

    function miniMaxSum(arr: number[]): void { let totalSum = 0; let minValue = Infinity; let maxValue = -Infinity;

    for (const num of arr){
        totalSum += num;
    
        if(num < minValue){
            minValue = num;
        }
    
        if(num > maxValue){
            maxValue = num;
        }
    }
    
    console.log(``${totalSum - maxValue} $`{totalSum - minValue}`)
    

    }