➽ Problem:-
https://www.hackerrank.com/challenges/mini-max-sum/problem
➽ Solution:-
#include<bits/stdc++.h>
using
namespace std;
int main()
{
vector<long int> arr;
for(int i=0;i<5;i++)
{
int x;
cin>>x;
arr.push_back(x);
}
sort(arr.begin(),arr.end());
long int max=0,min=0;
for(int i=1;i<=4;i++)
max += arr[i];
for(int i=0;i<4;i++)
min += arr[i];
cout << min << " "
<< max << endl;
return 0;
}
0 Comments
Please do not enter any spam link in the comment section.