I wanted to ask which one is better to use because avg. case complexity of set is log(n) while that of unordered_set is o(1) while worst case of set is same but that of unordered set is o(n).
And what are the points that we should take care of while using unordered_set so that we can work with no changes in inbuilt unordered_set?
Any help would be appreciated.
Unordered_set uses std::hash. You can get more about its cons in this article
I suggest you not to use unordered map/set in CF contest for a problem which has large constraints i.e. >= 1e4, because it have chances of being hacked. Better to use custom hashes for unordered_map/set if using as explained in this blog.
You may choose either one to use while adapting the problem you are solving.