alt_1234AA's blog

By alt_1234AA, history, 6 weeks ago, In English

I solved Subsequence LCM of Yesterdays Contest.

First I used map and "\n", it gave me tle

Then I used unordered map and "\n" gave AC.

wasted a lot of time :(.

Can anyone please tell me why this happened?

unordered_map Solution (AC): Link

Map solution (TLE) : Link

Thank you and have a nice day.

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

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

It is because time complexity of operations in map is o(log n) because it is implemented through red black tree whereas time complexity of operations in unordered map is o(1) since it is implemented using hash table.

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

Sad