Hashing in Data Structure
Last Updated :
09 Jun, 2025
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. It 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 (only keys) and dictionaries (key value pairs).

Basics
- Introduction
- Applications
- Separate Chaining for Collision Handling
- Open Addressing for Collision Handling
Easy Problems
- Check tor Subset
- Check for Disjoint
- Check for Equal
- Fizz Buzz
- 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 given range
- Missing Elements from Min to Max of Array
- Minimum Subsets with distinct elements
- Minimum Removals for No Common
- Pairs with given sum from different rows
Medium Problems
- 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
- Longest Subarray having Majority Elements Greater Than K
- Number of Employees Under every Employee
- Largest subarray with 0 sum
- Subarray with given sum
- Longest Consecutive subsequence
- Largest Fibonacci Subset
- Consecutive Subset Partitioning
- Distincts in every window of size k
- Insert, delete, search and getRandom
- Min insertions for a palindrome permutation
- 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 Problems
- Represent Fraction as String
- 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
- 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 :
Recommended: