Can we find the distance between two iterator in multiset with a complexity of less than O(n)?
I tried to use the std::distance() function provided with iterator header. But its internal implementation is O(n) for multiset iterator.
multiset::iterator models BidirectionalIterator, not RandomAccessIterator, so std::distance is only required to be linear, not constant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With