In a recent interview I was being asked how to write your own HashMap
/Hashtable
implementation in Java.
I have no idea of this so the only thing I said as a answer was that we can implement HashMap
by using Array, because only this provides constant time access, if you know the index. Key is to writing hash function to minimize collision.
Can you please advise me how we can write our own Hashmap
/Hashtable
?