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

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.

Why it would me Wrong answer, rather the chances are of tle when the solution is near the border of the time limit.

There are some questions in which using array gives AC but using Hashmaps gives tle.My concern is for such type of questions!!

Typo: I meant TLE not WA.

Sorry about that.

Ok, no problem.