Mini-Max Sum

  • + 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;
    }