rishabh05's blog

By rishabh05, history, 6 years ago, In English

set<int>s;
s.erase(s.begin());

I wanted to know whether removing the minimum element in set is a O(logN) or O(1) operation ?
I am quite confused about this situation.
Thanks in advance..

  • Vote: I like it
  • +20
  • Vote: I do not like it

»
6 years ago, # |
Rev. 2   Vote: I like it +20 Vote: I do not like it

It takes amortized constant time. See here set::begin and here set::erase.