Skip to main content

Practice · 1 of 2

min/max/sum with std::minmax_element

CHALLENGE
Difficulty: intermediate+25 XP

Implement Stats stats(const std::vector<int>& v) where Stats has int min; int max; long sum;. Return {0, 0, 0} for an empty vector. Use std::minmax_element for the extremes and accumulate the sum yourself (or with std::accumulate).

Back to lesson: Practice: Algorithm practice