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

Автор Aabhas99, история, 6 лет назад, По-английски

If we know the number of entries beforehand, lets say v, then is it optimal to initialise the hashmap in java with size v or v/load_factor???

If we donot intialize it then it will be of size 16 and many times rehashing would be done.

So, on an average in contests what size should be chosen for optimal solution??

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

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

In my experience, it does not make a significant difference.

Perhaps it may be "optimal" but it likely won't be the difference between a TLE and AC.

Hope this helps.

Edit: Changed WA to TLE.