Sunday, 2 April 2017

Hacker Rank Solution For " Mini-Max Sum " in C++

Problem :- Mini-Max Sum

Submit Your Solution Here :- Click Here

Copy The Code and paste it into hackerrank Editor .

Solution :-

#include <bits/stdc++.h>
using namespace std;

int main() {
    int val,i,j;
    long long int sum=0;
    vector<int> a;
    for(int i=0;i<5;i++){
        cin>>val;
        sum+=val;
        a.push_back(val);
    }
    sort(a.begin(), a.end());   
    cout<<sum-a[4]<<" "<<sum-a[0];  
    return 0;
}



Output :-

Hacker Rank Solution For " Mini-Max Sum " in C++

No comments:
Write comments

Recommended Posts × +