Open In App

Top 50 Problems on Hash Data Structure asked in SDE Interviews

Last Updated : 03 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Hashing is a technique or process of mapping keys, and values into the hash table by using a hash function. It is done for faster access to elements. The efficiency of mapping depends on the efficiency of the hash function used.

To learn more about hashing and hashmaps, please refer to the Tutorial on Hashing.

file.png

Given below are the most frequently asked interview questions on Hash:

Easy Level Problems on Hash Data Structure

Find whether an array is a subset of another array
Find the frequency of each character in a string
Find the first non-repeating character in a string
Find the intersection of two arrays
Find missing elements of a range
Find the pair with given sum in an array
Find the count of distinct elements in an array
Count number of Distinct Substring in a String
Print all distinct words from a paragraph
Count all distinct pairs with difference equal to k
Remove minimum number of elements such that no common element exist in both array
Minimum insertions to form a palindrome with permutations allowed
Find the only repetitive element between 1 to n-1
Remove duplicates from an array

Medium Level Problems on Hash Data Structure

Find the length of the longest consecutive sequence in an array
Find all pairs with a given sum in an array
Longest Consecutive Subsequence
Find the first repeating element in an array
Find the majority element in an array
Find the subarray with given sum in an array
Group all anagrams in an array of strings
Longest sub-array having sum k
Maximum length subarray with equal number of 0s and 1s
Print all subarrays with 0 sum
Sort an array according to the order defined by another array
Range Queries for Frequencies of array elements
Count subarrays having total distinct elements same as original array
All unique triplets that sum up to a given value
Smallest subarray with k distinct numbers
Maximum possible difference of two subsets of an array
Find the length of largest subarray with 0 sum
Find Itinerary from a given list of tickets
Find all pairs (a, b) in an array such that a % b = k
Count the number of subarrays having a given XOR

Hard Level Problems on Hash Data Structure

Top k numbers in a stream
Transform One String to Another using Minimum Number of Given Operation
Find the longest substring with k unique characters
Find the minimum window in a string containing all characters of another string
Implement LRU Cache
Longest subarray with sum divisible by k
Count distinct elements in every window of size k
Check if an array can be divided into pairs whose sum is divisible by k
Clone a Binary Tree with Random Pointers
Smallest window in a string containing all the characters of another string
Length of longest strict bitonic subsequence
Count maximum points on same line
Phone directory
Find number of Employees Under every Manager
Palindrome Substring Queries
Find All Duplicate Subtrees


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads