Aabhas99's blog

By Aabhas99, history, 6 years ago, In English

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??

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

»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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.