gjaiswal108's blog

By gjaiswal108, history, 5 years ago, In English

Getting TLE on using unordered_map, while AC on using map for problem E. Can anyone explain why??(I think unordered_map should be faster than map because its time complexity is O(1) for all operation.)

Link for Problem 1077E

Link for TLE Solution

Link for AC Solution

  • Vote: I like it
  • +7
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by gjaiswal108 (previous revision, new revision, compare).

»
5 years ago, # |
  Vote: I like it +9 Vote: I do not like it

Check this post

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

I think unordered_map should be faster than map because its time complexity is O(1) for all operation.

Whoever told you this didn't do a good job. Please. Learn some proper Computer Science.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks, I got to learn this now. I hv read it on geeksforgeeks, but didn't notice that it's average time complexity. There was not mentioned the worst case time complexity. (PS: I'm a beginner and learning.)

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it +21 Vote: I do not like it

      Please. Get yourself as far away from geeksforgeeks as you can. Their stuff is trashy. If you wanna learn, learn from academic papers/lectures. Even wikipedia is better than geeksforgeeks.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Thanks for your suggestion. You came to save my life from reading shitty post and making more mistake like this from now onwards.