Suppose I have an std::unordered_set<int> named as myset and I want to return a random number from myset in O(1) time. I first use rand() to generate a random number as:
int n = rand() % myset.size();
Then, I do:
myset.begin() + n;
I would like to know if myset.begin() + n is in O(n) or O(1)?
Thanks!