squatrian's blog

By squatrian, history, 6 months ago, In English

Thisis the code I submitted for this ques. Can someone help me understand why TLE is occurring?

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

»
6 months ago, # |
Rev. 4   Vote: I like it +4 Vote: I do not like it

unordered_set's insert and find have O(n) time complexity in the worst case. change it to the normal set

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Turns out the worst case of finding an item in an unordered map or set is O(n). I learnt it too the hard way when I used unordered map in one question then it got hacked later. Guess this was your canon event as well.

»
6 months ago, # |
Rev. 3   Vote: I like it +3 Vote: I do not like it