Hello
Is it possible to find max element in STL set with complexity O(lgN) ?
Hello
Is it possible to find max element in STL set with complexity O(lgN) ?
This should do the trick in constant time.Code:*set.rbegin();
I might be wrong.
Quoted more than 1000 times (I hope).Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
Right, thank You... heh that was so easy
there it is, log(n) time as requestedCode:max = *set.rbegin(); for (int i = 0; i < log(set.size()); i++) { max = *set.rbegin(); } return max;
Mhm thanks, but I think I will stick with O(1)