So, according to the link here: the max_element function is O(n), beacuase it touches at least every bucket of array apparently for all STL containers.