Hashing Data Structure

  • Last Updated : 22 Nov, 2022

Data Structure and Algorithms Course
Practice Problems on Hashing

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.

Let a hash function H(x) maps the value x at the index x%10 in an Array. For example if the list of values is [11,12,13,14,15] it will be stored at positions {1,2,3,4,5} in the array or Hash table respectively.

Hashing Data Structure

Recent Articles on Hashing

Topic :

Basics :


Easy :

  1. Find whether an array is subset of another array
  2. Union and Intersection of two linked lists
  3. Given an array A[] and a number x, check for pair in A[] with sum as x
  4. Minimum delete operations to make all elements of array same
  5. Minimum operation to make all elements equal in array
  6. Maximum distance between two occurrences of same element in array
  7. Count maximum points on same line
  8. Check if a given array contains duplicate elements within k distance from each other
  9. Find duplicates in a given array when elements are not limited to a range
  10. Find top k (or most frequent) numbers in a stream
  11. Most frequent element in an array
  12. Smallest subarray with all occurrences of a most frequent element
  13. First element occurring k times in an array
  14. Given an array of pairs, find all symmetric pairs in it
  15. Find the only repetitive element between 1 to n-1
  16. Find any one of the multiple repeating elements in read only array
  17. Find top three repeated in array
  18. Group multiple occurrence of array elements ordered by first occurrence
  19. How to check if two given sets are disjoint?
  20. Non-overlapping sum of two sets
  21. Find elements which are present in first array and not in second
  22. Check if two arrays are equal or not
  23. Pair with given sum and maximum shortest distance from end
  24. Pair with given product | Set 1 (Find if any pair exists)
  25. Find missing elements of a range
  26. k-th missing element in increasing sequence which is not present in a given sequence
  27. Find pair with greatest product in array
  28. Minimum number of subsets with distinct elements
  29. Remove minimum number of elements such that no common element exist in both arra
  30. Count items common to both the lists but with different prices
  31. Minimum Index Sum for Common Elements of Two Lists
  32. Find pairs with given sum such that elements of pair are in different rows
  33. Common elements in all rows of a given matrix
  34. Find distinct elements common to all rows of a matrix
  35. Find all permuted rows of a given row in a matrix
  36. Change the array into a permutation of numbers from 1 to n
  37. Count pairs with given sum
  38. Count pairs from two sorted arrays whose sum is equal to a given value x
  39. Count pairs from two linked lists whose sum is equal to a given value
  40. Count quadruples from four sorted arrays whose sum is equal to a given value x
  41. Number of subarrays having sum exactly equal to k
  42. Count pairs whose products exist in array
  43. Given two unsorted arrays, find all pairs whose sum is x
  44. Frequency of each element in an unsorted array
  45. Sort elements by frequency
  46. Find pairs in array whose sums already exist in array
  47. Find all pairs (a, b) in an array such that a % b = k
  48. Convert an array to reduced form | Set 1 (Simple and Hashing)
  49. Return maximum occurring character in an input string
  50. Group words with same set of characters
  51. Second most repeated word in a sequence
  52. Smallest element repeated exactly ‘k’ times (not limited to small range)
  53. Numbers with prime frequencies greater than or equal to k
  54. Find k numbers with most occurrences in the given array
  55. Find the first repeating element in an array of integers
  56. Find sum of non-repeating (distinct) elements in an array
  57. Non-Repeating Element
  58. k-th distinct (or non-repeating) element in an array.
  59. Print All Distinct Elements of a given integer array
  60. Only integer with positive value in positive negative value in array
  61. Pairs of Positive Negative values in an array

Intermediate :

  1. Find Itinerary from a given list of tickets
  2. Find number of Employees Under every Employee
  3. Count divisible pairs in an array
  4. Check if an array can be divided into pairs whose sum is divisible by k
  5. Longest subarray with sum divisible by k
  6. Subarray with no pair sum divisible by K
  7. Print array elements that are divisible by at-least one other
  8. Find three element from different three arrays such that that a + b + c = sum
  9. Find four elements a, b, c and d in an array such that a+b = c+d
  10. Find the largest subarray with 0 sum
  11. Printing longest Increasing consecutive subsequence
  12. Longest Increasing consecutive subsequence
  13. Longest subsequence such that difference between adjacents is one | Set 2
  14. Longest Consecutive Subsequence
  15. Largest increasing subsequence of consecutive integers
  16. Count subsets having distinct even numbers
  17. Count distinct elements in every window of size k
  18. Maximum possible sum of a window in an array such that elements of same window in other array are unique
  19. Distributing items when a person cannot take more than two items of same type
  20. Design a data structure that supports insert, delete, search and getRandom in constant time
  21. Check if array contains contiguous integers with duplicates allowed
  22. Length of the largest subarray with contiguous elements
  23. Find if there is a subarray with 0 sum
  24. Print all subarrays with 0 sum
  25. Find subarray with given sum | Set 2 (Handles Negative Numbers)
  26. Find four elements that sum to a given value
  27. Implementing our Own Hash Table with Separate Chaining in Java
  28. Implementing own Hash Table with Open Addressing Linear Probing in C++
  29. Vertical Sum in a given Binary Tree
  30. Group Shifted String
  31. Minimum insertions to form a palindrome with permutations allowed
  32. Check for Palindrome after every character replacement Query
  33. Maximum length subsequence with difference between adjacent elements as either 0 or 1 | Set 2
  34. Maximum difference between frequency of two elements such that element having greater frequency is also greater
  35. Difference between highest and least frequencies in an array
  36. Maximum difference between first and last indexes of an element in array
  37. Maximum possible difference of two subsets of an array
  38. Sorting using trivial hash function
  39. Smallest subarray with k distinct numbers
  40. Longest subarray not having more then K distinct elements
  41. Sum of f(a[i], a[j]) over all pairs in an array of n integers
  42. Find number of pairs in an array such that their XOR is 0
  43. Maximize elements using another array

Hard :

Misc :

Quick Links :


If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up