A hash function converts a key to an array index. For key : Good hash functions distribute keys uniformly.
Different keys mapping to the same index is called a collision. You don't need to implement hash functions in contests. Use the built-in: C++ has unordered_map and unordered_set, Python has dict and set.