Skip to main content

Practice ยท 1 of 2

min/max/sum with std::minmax_element

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).

Difficulty: intermediate

Back to lesson: Practice: Algorithm practice