You are viewing a single comment's thread. Return to all comments →
Not the most efficient solution (can be done in one pass), but really idiomatic in my opinion.
void miniMaxSum(const vector<int> &a) { unsigned long long tmp = std::accumulate(a.begin(), a.end(), 0L); auto result = std::minmax_element(a.begin(), a.end()); std::cout << tmp - *result.second << " " << tmp - *result.first; }
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 →
Not the most efficient solution (can be done in one pass), but really idiomatic in my opinion.