For strings, you can use the string cryptographic hash as the key for the hash table. This usually results in an even distribution of the hash keys, which is a good hash table property.
If you want to narrow the key size (for example, only 32 bits), you can still choose a cryptographic hash function like SHA-256 and use the lower 32 bits.
You can also represent the number as a string or as binary data and calculate a cryptographic hash to ensure uniform distribution of keys.
Once your keys are evenly distributed, you do not need to use a complex hash function - you can simply map the range of keys into cells with the same size.
To better prepare for the interview, you can read this one .
Lior kogan
source share