Блог пользователя shivanshsingh9670

Автор shivanshsingh9670, история, 21 месяц назад, По-английски

Question

In my both solutions, i am storing the frequencies of the values in maps and then pushing in priority queue. When I use unordered_map, it throws tle. But if I use map, it is accepted. Can someone explain Why ?

Unordered_map Solution — TLE

Map Solution — Acceppted

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
21 месяц назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

This is a very common mistake for beginners. All people think that unordered_map time is O(1), but actually average time is O(1). When storing large prime numbers, the time can get up to O(n)