Hash Function
5 problems · 4 with full explanations
2 Easy1 Medium0 Hard
Custom hash functions reduce collisions in hash maps. Polynomial rolling hash H(s) = s[0]·pⁿ⁻¹ + ... + s[n-1] is common for strings. Use double hashing (two independent hashes) to reduce collision probability to near zero.
How to practice
To practice Hash Function problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the hash function pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.