map is faster in cpp than unordered_map?
So today I was up solving Codeforces Round #790 (Div. 4) i got stuck in problem F bc i was using unordered_map and repetedly getting tle at 19th and 20th testcase i gave up and tried to look into solution i found out they were using map i tried it and it gets accepted instantaneously, then i wonder which map is faster, tried to look into some online resources but found oppsosite of it every online resource was say unordered_map is faster than map here is my submissions with map unordered_map someone plz help me in this i am really confused, i might get downvote for this but i just want to know the reason thank u
read this
average case time complexity : unordered_map O(1) < map O(logn)
worst case time complexity : unordered_map O(n) > map O(logn)
unordered_map suffers with collision issue if test cases are made that way. please read their internal implementation for more details.
unordered_map is usually faster in general and takes O(1) time for most its commands, though, on some special calls it takes O(n) time, and it's possible to generate test cases so that unordered_map takes O(n) time everytime you use it, which testers mostly put in their tests. Check out this blog for deeper understanding and on how to bypass those testcases. https://codeforces.net/blog/entry/62393