• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

Hashing in Data Structure

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).

Here’s an example of hashing using the modulo method. The hash function H(x) = x % 10 converts any large number into a smaller value between 0 and 9.

H(x) = x % 10

frame_3274
frame_3274

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
  • 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 of a Range
  • Missing from Min to Max of Array
  • Minimum Subsets with distinct
  • Minimum Removals for No Common
  • Maximum points on the same line

Medium Problems

  • Pair Sums Divisible by k
  • 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 with Majority 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
  • 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) .

Hard Problems

  • Represent Fraction as String
  • 4 Sum – Count quadruplets
  • 4 Sum – Find all Quadruplets
  • 4 Sum - From four sorted arrays
  • Largest subarray with equal 0s and 1s
  • Longest Common Sum Span
  • Palindrome Substring Queries
  • Subarrays having distinct count
  • Maximum array from two arrays
  • Sum of all unique sub-array sums.
  • Recaman’s sequence
  • Longest strict bitonic subsequence
  • Duplicate Subtrees
  • Submatrix with corners as 1

Quick Links :

  • Practice Problems on Hashing
  • Hashing Interview Questions
  • Quiz on Hashing
  • DSA Tutorial