Hashing Mastery Guide
Hashing Mastery Guide
1. What is Hashing?
Hashing is a method to map data to a fixed-size value (hash). Uses a hash function to map
keys to a fixed-size table.
Efficient for insertion, deletion, and search — average time complexity is O(1).
3. Direct Addressing
Simple array-based mapping. Only works if keys are small and non-negative integers.
6. Double Hashing
7. Polynomial Hashing
8. Rolling Hash
return hash;
}
long long substringHash(int l, int r, vector<long long>& hash, vector<long long>& power) {
long long h = (hash[r + 1] - hash[l] + MOD) % MOD;
h = (h * power[100000 - l]) % MOD;
return h;
}