Hashing in Data Structure
Last Updated :
21 Nov, 2024
Improve
Hashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access.
- Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function that enables fast retrieval of information based on its key.
- The great thing about hashing is, we can achieve all three operations (search, insert and delete) in O(1) time on average.
- Hashing is mainly used to implement a set of distinct items and dictionaries (key value pairs).

Basics of Hashing in Data Structure
- Introduction to Hashing
- Applications of Hashing
- Index Mapping (or Trivial Hashing)
- Separate Chaining for Collision Handling
- Open Addressing for Collision Handling
- Double Hashing
- Load Factor and Rehashing
Easy Problem on Hashing
- Check tor Subset
- Check for Disjoint
- Check for Equal
- Max distance between two occurrences
- Duplicate within K Distance
- Intersection of Two Arrays
- Union of Two Arrays
- Most Frequent Element
- Maximum points on the same line
- 2 Sum - Find if there is any pair
- 2 Sum - Count Pairs
- Count Pairs with Given Diff
- Only repetitive element from 1 to n-1
- Missing elements of a range
- Minimum Subsets with distinct elements
- Minimum Removals for No Common
- Pairs with given sum having elements from different rows
Medium Problem on Hashing
- Check If Array Pair Sums Divisible by k
- Longest subarray with sum divisible by k
- 3 Sum - Count all triplets with given sum
- 3 Sum – Find All Triplets with Zero Sum
- Itinerary from a given list of tickets
- Number of Employees Under every Employee
- Largest subarray with 0 sum
- Subarray with given sum
- Longest Increasing consecutive subsequence
- Minimum Consecutive Subset Partitioning
- Distincts in every window of size k
- Data Structure with insert, delete, search and getRandom
- Minimum insertions for a palindrome with permutations
- Maximum possible difference of two subsets of an array
- Sorting using trivial hash function
- Smallest subarray with k distinct numbers
- All pairs (a, b) in an array such that a % b = k
- Group words with same set of characters
- k-th distinct (or non-repeating) element in an array.
Hard Problem on Hashing
- 4 Sum – Count quadruplets
- 4 Sum – Find all Quadruplets
- 4 Sum - From four sorted arrays
- Clone a Binary Tree with Random Pointers
- Largest subarray with equal number of 0s and 1s
- Longest Common Sum Span
- Palindrome Substring Queries
- Range Queries for Frequencies of array elements
- Elements to be added so that all elements of a range are present in array
- Cuckoo Hashing – Worst case O(1) Lookup!
- Count subarrays having total distinct elements same as original array
- Maximum array from two given arrays keeping order same
- Find Sum of all unique sub-array sum for a given array.
- Recaman’s sequence
- Length of longest strict bitonic subsequence
- Find All Duplicate Subtrees
- Find if there is a rectangle in binary matrix with corners as 1
Quick Links :
- ‘Practice Problems’ on Hashing
- Top 20 Hashing Technique based Interview Questions
- ‘Quizzes’ on Hashing
- ‘Videos’ on Hashing
Recommended:


