Šimon Tóth’s Post

View profile for Šimon Tóth

C++ Educational Content Creator | 20 years of Software Engineering experience distilled into digestible daily posts

The std::min_element, std::max_element and (C++11) std::minmax_element are min-max algorithms that operate on top of iterators, returning an iterator to the minimum/maximum element. The algorithms provide parallel (C++17) variants and are constexpr and range enabled (C++20). C++20 also offers a simpler alternative: a range overload of the base min-max algorithms. Compiler Explorer link: https://lnkd.in/enZSnYbn #cpp #cplusplus #coding #programming #dailybiteofcpp

  • text

a little less known fact is that using std::minmax_element is more efficient than using std::min_element and std::max_element separately. Its complexity is at most max(floor((3/2)*(N−1)), 0) which is why this used to be a fairly common interview questions at FAANG.

To view or add a comment, sign in

Explore content categories