We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
void miniMaxSum(vector arr) {
if(arr.size() == 0) return;
sort(arr.begin(), arr.end());
long long int min = accumulate(arr.begin()+0, arr.begin()+4, 0);
long long int max = accumulate(arr.begin()+1, arr.begin()+5, 0);
cout << min << " " << max;
}
This is the approach I came with but some of the test cases are failing
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
void miniMaxSum(vector arr) { if(arr.size() == 0) return; sort(arr.begin(), arr.end()); long long int min = accumulate(arr.begin()+0, arr.begin()+4, 0); long long int max = accumulate(arr.begin()+1, arr.begin()+5, 0); cout << min << " " << max; }
This is the approach I came with but some of the test cases are failing