Humam Helfawi - 1 year ago 110

C++ Question

What is the most efficient and standard (C++11/14) way to find the max/min item of vector of vectors?

`std::vector<std::vector<double>> some_values{{5,0,8},{3,1,9}};`

the wanted max element is

the wanted min element is

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Any efficient way to calculate the maximum element in a 2-D array(or vector in your case) involves a complexity of `O(n^2)`

irrespective of what you do, as the calculation involves a comparison between `n*n`

elements.Best way in terms of ease of use is to use `std::max_element`

on the vector of vectors.I will not delve into details.Here is the reference.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**