I was asked to code this question : https://leetcode.com/problems/insert-delete-getrandom-o1/ Further the interviewer asked me to give an example where searching complexity of HashMap is not O(1) ?
Anonymous
Usually, when the hash table (in this case a hashmap) has a collision when hashing your key, it can store two different keys and values in the same position in memory. So, once you have two values for one position or more, you have an O(N) search to return you a key. A collision occurs when your memory reach the limit.
Check out your Company Bowl for anonymous work chats.