Hashing Data Structure

Hashing is an important Data Structure which is designed to use a special function called the Hash function which is used to map a given value with a particular key for faster access of elements. The efficiency of mapping depends of 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.

Recent Articles on Hashing

Topic :

Basics :

Easy :

  1. Print a Binary Tree in Vertical Order | Set 2 (Hashmap based Method)
  2. Find whether an array is subset of another array
  3. Union and Intersection of two linked lists
  4. Given an array A[] and a number x, check for pair in A[] with sum as x
  5. Minimum delete operations to make all elements of array same
  6. Minimum operation to make all elements equal in array
  7. Maximum distance between two occurrences of same element in array
  8. Count maximum points on same line
  9. Check if a given array contains duplicate elements within k distance from each other
  10. Find duplicates in a given array when elements are not limited to a range
  11. Find top k (or most frequent) numbers in a stream
  12. Most frequent element in an array
  13. Smallest subarray with all occurrences of a most frequent element
  14. First element occurring k times in an array
  15. Given an array of pairs, find all symmetric pairs in it
  16. Find the only repetitive element between 1 to n-1
  17. Find any one of the multiple repeating elements in read only array
  18. Find top three repeated in array
  19. Group multiple occurrence of array elements ordered by first occurrence
  20. How to check if two given sets are disjoint?
  21. Non-overlapping sum of two sets
  22. Find elements which are present in first array and not in second
  23. Check if two arrays are equal or not
  24. Pair with given sum and maximum shortest distance from end
  25. Pair with given product | Set 1 (Find if any pair exists)
  26. Find missing elements of a range
  27. k-th missing element in increasing sequence which is not present in a given sequence

  28. Find pair with greatest product in array
  29. Minimum number of subsets with distinct elements
  30. Remove minimum number of elements such that no common element exist in both arra
  31. Count items common to both the lists but with different prices
  32. Minimum Index Sum for Common Elements of Two Lists
  33. Find pairs with given sum such that elements of pair are in different rows
  34. Common elements in all rows of a given matrix
  35. Find distinct elements common to all rows of a matrix
  36. Find all permuted rows of a given row in a matrix
  37. Change the array into a permutation of numbers from 1 to n
  38. Count pairs with given sum
  39. Count pairs from two sorted arrays whose sum is equal to a given value x
  40. Count pairs from two linked lists whose sum is equal to a given value
  41. Count quadruples from four sorted arrays whose sum is equal to a given value x
  42. Number of subarrays having sum exactly equal to k
  43. Count pairs whose products exist in array
  44. Given two unsorted arrays, find all pairs whose sum is x
  45. Frequency of each element in an unsorted array
  46. Sort elements by frequency
  47. Find pairs in array whose sums already exist in array
  48. Find all pairs (a, b) in an array such that a % b = k
  49. Convert an array to reduced form | Set 1 (Simple and Hashing)
  50. Return maximum occurring character in an input string
  51. Group words with same set of characters
  52. Second most repeated word in a sequence
  53. Smallest element repeated exactly ‘k’ times (not limited to small range)
  54. Numbers with prime frequencies greater than or equal to k
  55. Find k numbers with most occurrences in the given array
  56. Find the first repeating element in an array of integers
  57. Find sum of non-repeating (distinct) elements in an array
  58. Non-Repeating Element
  59. k-th distinct (or non-repeating) element in an array.
  60. Print All Distinct Elements of a given integer array
  61. Only integer with positive value in positive negative value in array
  62. 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 contribute.geeksforgeeks.org or mail your article to contribute@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