I used to believe that unordered_map is better in time-complexity than map in C++. But today while I was doing a problem(Molly's Chemicals), I got time-limit exceeded. After a lot of guess-work(because I thought my solution was correct), I tried using a map instead of an unordered_map and as a surprise I got it accepted.In some cases in which due to a lot of collisions unordered_map can have a big constant multiplier which will increase its actual complexity to greater than that of a map(corrections are welcomed).
i searched a lot about time complexity
of different functions of maps and unordered maps
but i didnt find a proper content as i want to know that when should i use maps or unordered maps. Can anybody please explain difference between the use of maps and unoredered_maps in terms of time complexity.