Design HashMap
Easy · Hashing · about 20 minutes
Asked at Amazon, Microsoft, Google, ByteDance, Apple.
Design a hash map without using any built-in hash table library.
MyHashMap()creates an empty map.put(key, value)inserts or updates the pair.get(key)returns the value forkey, or -1 if it's absent.remove(key)removes the key if present.
Keys and values are in 0..10⁶.