Hash Table Coding Problems: 439 Questions with Solutions
439 hash table coding problems — 134 easy · 250 medium · 55 hard — with solutions in 13 languages. Plus a step-by-step walkthrough and a 8-day plan.
- Problems: 439
- By difficulty: 134 easy · 250 medium · 55 hard
- Languages: JavaScript, TypeScript, Python, Java, C++, C, C#, Go, Kotlin, Swift, Rust, PHP and Ruby
- Cost: Free on every plan; sign in to run and submit
A hash map turns "have I seen this before?" into a constant-time question. The problems here are the classic exchanges of memory for time: counting occurrences, pairing complements (Two Sum), grouping anagrams, detecting duplicates, remembering the index of a value so a second pass can look back. Knowing when a map is the right tool — and when a fixed-size array or a set does the same job for less — is what they practise.
New to hash table? Read the Hashing: Hash Maps and Hash Sets tutorial first.
How hash table works, step by step
nums = [7, 3, 9, 4, 12, 2], target = 14- For each number, the partner it needs is 14 − nums[i]. A map from value to index answers "seen it before?" in O(1), so a single pass is enough; the map starts empty.
- nums[0] = 7 needs 14 − 7 = 7. The map is still empty — looking before storing is what stops 7 pairing with itself — so store 7 → 0.
- nums[1] = 3 needs 11, which is not in the map, so no earlier number pairs with it. Store 3 → 1 for the numbers still to come.
- nums[2] = 9 needs 5: not in the map either, so store 9 → 2.
- nums[3] = 4 needs 10: not in the map either, so store 4 → 3.
- nums[4] = 12 needs 2: not in the map either, so store 12 → 4.
- nums[5] = 2 needs 14 − 2 = 12, and the map says 12 is at index 4: the answer is [4, 5]. One lookup and one store per number make it O(n) time and O(n) space, against O(n²) for every pair.
Hash Table study plan
14 of the 439 Hash Table problems (4 easy, 7 medium and 3 hard) over 8 days, about 8 h 10 min in all — the pattern first, then easiest to hardest. After that, the other 425 in the full list below are practice at your own pace. Then move on to Counting.
Day 1
Learn the pattern: read the essentials and step through the walkthrough above, then solve these 3.
- Contains Duplicate Easy
- Two Sum Easy
- Jewels and Stones Easy
Day 2
Medium problems: the same pattern with one twist each. Name the twist before you code.
Day 3
More mediums. Before coding each one, write down what state the pattern keeps and when it changes.
Day 4
More mediums. Before coding each one, write down what state the pattern keeps and when it changes.
- Permutation in String Medium
- Subarray Sum Equals K Medium
Day 5
More mediums. Before coding each one, write down what state the pattern keeps and when it changes.
- Contiguous Array Medium
- Continuous Subarray Sum Medium
Day 6
Hard problems: the pattern combined with a second idea. Give each a full attempt before reading the editorial.
Day 7
Another hard one. If it beats you after a real attempt, read the editorial, then solve it again tomorrow from memory.
- Word Ladder Hard
Day 8
Another hard one. If it beats you after a real attempt, read the editorial, then solve it again tomorrow from memory.
Hash Table: the essentials
When to reach for it
The brute force has a nested loop whose inner loop only searches — for a complement, a duplicate, an earlier index, an equal key. Replace that search with a lookup. Other signals: "group by", "first unique", "how many times", or a need to remember where a value was last seen.
The pattern
Decide what the key is and what the value records. For pairing, check for the partner before storing the current element, so nothing pairs with itself. For grouping, compute a canonical key — a word's sorted letters, or its tuple of letter counts — and append to that key's list. Plain tallies have their own page: Counting.
def two_sum(nums, target):
seen = {} # value -> index
for i, x in enumerate(nums):
if target - x in seen:
return [seen[target - x], i]
seen[x] = i
return []
Cost
Expected O(1) per insert and lookup, so a pass is O(n) time and up to O(n) space. Two caveats: hashing a string key costs O(length), and many colliding keys make each operation linear — adversarial inputs can do that to C++'s unordered_map. Iteration order is not guaranteed by Java's HashMap or C++'s unordered_map; Python's dict and JavaScript's Map keep insertion order.
Common mistakes
- Storing before checking, so
x + x == targetfinds the element itself. - Using an array as a key: Python refuses a list, and Java hashes an
int[]by identity, so two equal arrays miss each other. Use a tuple or a string. - A map where keys are small integers or lowercase letters; a plain array is faster.
- Relying on the iteration order of a map that does not promise one.
Start with
- Two Sum: the complement lookup in its simplest form.
- Contains Duplicate: a set as the "seen before" test.
- Longest Consecutive Sequence: O(n) where sorting would be O(n log n).
All hash table problems
Easy (134)
- Design Neighbor Sum Service Array, Matrix, Simulation
- Design an Ordered Stream Array, Design
- Design HashMap Array, Design
- Design HashSet Array, Design
- Remove Duplicates from an Unsorted Linked List Linked List
- Two Sum IV - Input is a BST Tree, Depth-First Search, Two Pointers
- Check if Any Element Has Prime Frequency Array, Math, Counting
- Find Most Frequent Vowel and Consonant String, Counting
- Find the Largest Almost Missing Integer Array
- Maximum Difference Between Even and Odd Frequency I String, Counting
- Find Valid Pair of Adjacent Digits in String String, Counting
- Minimum Number of Operations to Make Elements in Array Distinct Array
- Minimum Operations to Make Array Values Equal to K Array
- Count the Number of Special Characters I String
- Smallest Missing Integer Greater Than Sequential Prefix Sum Array, Sorting
- Find Common Elements Between Two Arrays Array
- Subarrays Distinct Element Sum of Squares I Array
- Max Pair Sum in an Array Array
- Find Maximum Number of String Pairs Array, String, Simulation
- Check Distances Between Same Letters Array, String
- Find Subarrays With Equal Sum Array
- Merge Similar Items Array, Sorting, Ordered Set
- Make Array Zero by Subtracting Equal Amounts Array, Greedy, Sorting
- Most Frequent Number Following Key In an Array Array, Counting
- Shortest Completing Word Array, String
- Find X-Sum of All K-Long Subarrays I Array, Sliding Window, Heap (Priority Queue)
- Greatest English Letter in Upper and Lower Case String, Enumeration
- Find Resultant Array After Removing Anagrams Array, String, Sorting
- Check Whether Two Strings are Almost Equivalent String, Counting
- Kth Distinct String in an Array Array, String, Counting
- Second Largest Digit in a String String
- Check if One String Swap Can Make Strings Equal String, Counting
- Path Crossing String
- Increasing Decreasing String String, Counting
- Uncommon Words from Two Sentences String, Counting
- Keep Multiplying Found Values by Two Array, Sorting, Simulation
- Check if Every Row and Column Contains All Numbers Array, Matrix
- Finding 3-Digit Even Numbers Array, Enumeration, Sorting
- Two Out of Three Array, Bit Manipulation
- Count Special Quadruplets Array, Enumeration
- Check if All the Integers in a Range Are Covered Array, Prefix Sum
- Check Array Formation Through Concatenation Array
- Make Two Arrays Equal by Reversing Subarrays Array, Sorting
- Find the Losers of the Circular Game Array, Simulation
- Form Smallest Number From Two Digit Arrays Array, Enumeration
- Most Frequent Even Element Array, Counting
- Rearrange Characters to Make Target String String, Counting
- Decode the Message String
- Existence of a Substring in a String and Its Reverse String
- Find the XOR of Numbers Which Appear Twice Array, Bit Manipulation
- Number of Beautiful Pairs Array, Math, Counting
- Check if Array is Good Array, Sorting
- Split the Array Array, Counting
- Best Poker Hand Array, Counting, Greedy
- Substrings of Size Three with Distinct Characters String, Sliding Window, Counting
- Count Number of Pairs With Absolute Difference K Array, Counting
- Intersection of Multiple Arrays Array, Counting
- Check if Number Has Equal Digit Count and Digit Value String, Counting
- Number of Distinct Averages Array, Two Pointers, Sorting
- Check if The Number is Fascinating Math, String
- Counting Elements Array, Counting
- Largest Unique Number Array, Sorting
- Rings and Rods String, Bit Manipulation
- Check if All Characters Have Equal Number of Occurrences String, Counting
- Find Words That Can Be Formed by Characters String, Counting
- Most Common Word String
- Largest Substring Between Two Equal Characters String
- Count Pairs With Given Sum Array
- Sort the People Array, Sorting
- Find Missing and Repeated Values Matrix, Math
- Minimum Operations to Collect Elements Array, Simulation
- Find the Distinct Difference Array Array, Prefix Sum
- The Two Sneaky Numbers of Digitville Array
- Find the Difference of Two Arrays Array
- Largest Positive Integer That Exists With Its Negative Array, Two Pointers
- Maximum Number of Pairs in Array Array, Counting
- Rank Transform of an Array Array, Sorting
- N-Repeated Element in Size 2N Array Array
- Find Common Characters Array, String
- Keyboard Row Array, String
- Minimum Index Sum of Two Lists Array, String
- Count Elements With Maximum Frequency Array, Counting
- Sum of Unique Elements Array, Counting
- Unique Number of Occurrences Array
- Maximum Number of Balls in a Box Math, Counting
- Permutation Difference between Two Strings String
- Odd String Difference Array, String
- First Letter to Appear Twice String
- Count Common Words With One Occurrence Array, String
- Maximum Number of Words You Can Type String
- Number of Different Integers in a String String
- Verifying an Alien Dictionary Array, String
- Unique Morse Code Words Array, String
- Divide Array Into Equal Pairs Array, Bit Manipulation
- Count Largest Group Math
- Find Lucky Integer in an Array Array, Counting
- Fair Candy Swap Array
- Count the Number of Consistent Strings Array, String, Bit Manipulation
- Find the Difference String, Bit Manipulation, Sorting
- Sort Array by Increasing Frequency Array, Sorting
- Find Winner on a Tic Tac Toe Game Array, Matrix, Simulation
- Number of Equivalent Domino Pairs Array, Counting
- Number of Arithmetic Triplets Array, Two Pointers, Enumeration
- Minimum Common Value Array, Two Pointers, Binary Search
- Check If N and Its Double Exist Array, Two Pointers, Sorting
- Maximum Number of Balloons String, Counting
- Unique Email Addresses Array, String
- Buddy Strings String
- Check if the Sentence Is Pangram String
- Jewels and Stones String
- Longest Palindrome String, Greedy
- Ransom Note String, Counting
- First Unique Character in a String String, Queue, Counting
- Relative Sort Array Array, Sorting, Counting Sort
- Distribute Candies Array, Greedy
- Longest Harmonious Subsequence Array, Sorting, Sliding Window
- Degree of an Array Array
- Number of Good Pairs Array, Math, Counting
- How Many Numbers Are Smaller Than the Current Number Array, Counting Sort
- Set Mismatch Array, Bit Manipulation, Sorting
- Intersection of Two Arrays II Array, Two Pointers, Sorting
- Intersection of Two Arrays Array, Two Pointers, Sorting
- Contains Duplicate II Array, Sliding Window
- Roman to Integer Math, String
- Happy Number Math, Two Pointers
- Find the Town Judge Graph
- Next Greater Element I Array, Stack
- Word Pattern String
- Isomorphic Strings String
- Find All Numbers Disappeared in an Array Array
- Majority Element Array, Divide and Conquer
- Contains Duplicate Array, Sorting
- Valid Anagram String, Sorting, Counting
- Two Sum Array
Medium (250)
- Implement Router Array, Binary Search, Queue
- Design Task Manager Heap (Priority Queue), Ordered Set, Design
- Frequency Tracker Counting, Design
- Find Consecutive Integers from a Data Stream Queue, Counting, Design
- Design Memory Allocator Array, Simulation, Design
- Longest Uploaded Prefix Binary Search, Union Find, Design
- Design a Food Rating System Array, String, Heap (Priority Queue)
- Design a Number Container System Heap (Priority Queue), Ordered Set, Design
- Smallest Number in Infinite Set Heap (Priority Queue), Ordered Set, Design
- Design Bitset Array, String, Design
- Range Frequency Queries Array, Binary Search, Segment Tree
- Simple Bank System Array, Simulation, Design
- Stock Price Fluctuation Design, Heap (Priority Queue), Ordered Set
- Detect Squares Array, Counting, Design
- Operations on Tree Array, Tree, Depth-First Search
- Finding Pairs With a Certain Sum Array, Design
- Design Authentication Manager Linked List, Design
- Throne Inheritance Tree, Depth-First Search, Design
- Tweet Counts Per Frequency Binary Search, Sorting, Ordered Set
- Snapshot Array Array, Binary Search, Design
- Time Based Key-Value Store String, Binary Search, Design
- Online Election Array, Binary Search, Design
- Design Twitter Heap (Priority Queue), Design
- Map Sum Pairs String, Trie, Design
- Implement Magic Dictionary String, Depth-First Search, Trie
- Implement Trie (Prefix Tree) String, Trie, Design
- LRU Cache Design
- Union of Two Linked Lists Linked List, Sorting
- Delete Nodes From Linked List Present in Array Array, Linked List
- Linked List Components Linked List, Array
- Duplicate Subtree in Binary Tree Tree, Depth-First Search
- Vertical Sum of Binary Tree Tree, Depth-First Search
- Bottom View of Binary Tree Tree, Breadth-First Search
- Top View of Binary Tree Tree, Breadth-First Search
- Cousins in Binary Tree II Tree, Breadth-First Search
- Create Binary Tree From Descriptions Tree, Array
- Smallest Subtree with all the Deepest Nodes Tree, Depth-First Search, Breadth-First Search
- All Nodes Distance K in Binary Tree Tree, Depth-First Search, Breadth-First Search
- Most Frequent Subtree Sum Tree, Depth-First Search
- Path Sum III Tree, Depth-First Search, Prefix Sum
- Construct Binary Tree from Inorder and Postorder Traversal Tree, Array, Divide and Conquer
- Construct Binary Tree from Preorder and Inorder Traversal Tree, Array, Divide and Conquer
- Intervals Between Identical Elements Array, Prefix Sum
- Maximum Number of Non-Overlapping Subarrays With Sum Equals Target Array, Greedy, Prefix Sum
- Partition String String, Trie, Simulation
- Count Special Triplets Array, Counting
- Count Covered Buildings Array, Sorting
- Closest Equal Element Queries Array, Binary Search
- Count Special Subsequences Array, Math, Enumeration
- Identify the Largest Outlier in an Array Array, Counting, Enumeration
- Rearrange K Substrings to Form Target String String, Sorting
- Report Spam Message Array, String
- Count Almost Equal Pairs I Array, Sorting, Counting
- Find Occurrences of an Element in an Array Array
- Minimum Length of Anagram Concatenation String, Counting
- Minimum Number of Operations to Make Word K-Periodic String, Counting
- Count the Number of Special Characters II String
- Find the Length of the Longest Common Prefix Array, String, Trie
- Find the Maximum Number of Elements in Subset Array, Enumeration
- Maximum Square Area by Removing Fences From a Field Array, Enumeration
- Count Pairs of Points With Distance k Array, Bit Manipulation
- Check if Strings Can be Made Equal With Operations II String, Sorting
- Minimum Seconds to Equalize a Circular Array Array, Greedy
- Minimum Index of a Valid Split Array, Sorting
- Number of Black Blocks Array, Enumeration
- Relocate Marbles Array, Sorting, Simulation
- Max Sum of a Pair With Equal Sum of Digits Array, Sorting, Heap (Priority Queue)
- Sender With Largest Word Count Array, String, Counting
- Count Artifacts That Can Be Extracted Array, Simulation
- Minimum Operations to Make the Array Alternating Array, Greedy, Counting
- Finding the Users Active Minutes Array
- Number of Ways Where Square of Number Is Equal to Product of Two Numbers Array, Math, Two Pointers
- Check If Array Pairs Are Divisible by k Array, Counting
- Making File Names Unique Array, String
- Construct K Palindrome Strings String, Greedy, Counting
- Flip Columns For Maximum Number of Equal Rows Array, Matrix
- Vowel Spellchecker Array, String
- Card Flipping Game Array
- Rabbits in Forest Array, Math, Greedy
- Shortest Uncommon Substring in an Array Array, String, Trie
- Find Longest Special Substring That Occurs Thrice I String, Binary Search, Sliding Window
- Count Beautiful Substrings I Math, String, Enumeration
- Sum of Beauty of All Substrings String, Counting
- Invalid Transactions Array, String, Sorting
- Binary String With Substrings Representing 1 To N String, Bit Manipulation, Sliding Window
- Longest Uncommon Subsequence II Array, Two Pointers, String
- Power Grid Maintenance Array, Depth-First Search, Breadth-First Search
- Find Subtree Sizes After Changes Array, String, Tree
- Maximum Frequency After Subarray Operation Array, Dynamic Programming, Greedy
- Total Characters in String After Transformations I Math, String, Dynamic Programming
- Find Maximum Removals From Source String Array, Two Pointers, String
- Maximum Total Damage With Spell Casting Array, Two Pointers, Binary Search
- Minimum Substring Partition of Equal Character Frequency String, Dynamic Programming, Counting
- Partition String Into Minimum Beautiful Substrings String, Dynamic Programming, Backtracking
- Non-decreasing Subsequences Array, Backtracking, Bit Manipulation
- Minimum Operations to Write the Letter Y on a Grid Array, Matrix, Counting
- Difference of Number of Distinct Values on Diagonals Array, Matrix
- Find the Maximum Length of a Good Subsequence I Array, Dynamic Programming
- Extra Characters in a String String, Dynamic Programming, Trie
- Maximum Earnings From Taxi Array, Dynamic Programming, Sorting
- Length of Longest Fibonacci Subsequence Array, Dynamic Programming
- Binary Trees With Factors Array, Dynamic Programming, Sorting
- Minimum Number of Groups to Create a Valid Assignment Array, Greedy
- Describe the Painting Array, Sorting, Prefix Sum
- Reward Top K Students String, Sorting, Heap (Priority Queue)
- Mark Elements on Array by Performing Queries Array, Sorting, Heap (Priority Queue)
- Next Greater Frequency Element Array, Stack, Monotonic Stack
- Count Number of Rectangles Containing Each Point Array, Binary Search, Sorting
- Minimum Absolute Difference Queries Array, Binary Search, Prefix Sum
- Count Substrings With K-Frequency Characters I String, Sliding Window
- Count of Substrings Containing Every Vowel and K Consonants I String, Sliding Window
- Count Substrings That Can Be Rearranged to Contain a String I String, Sliding Window
- K Divisible Elements Subarrays Array, Trie, Enumeration
- Count of Interesting Subarrays Array, Prefix Sum
- Maximum Sum of Almost Unique Subarray Array, Sliding Window
- Minimum Moves to Make Array Complementary Array, Prefix Sum
- Substring XOR Queries Array, String, Bit Manipulation
- Largest Combination With Bitwise AND Greater Than Zero Array, Bit Manipulation, Counting
- Distinct Prime Factors of Product of Array Array, Math, Number Theory
- Count Lattice Points Inside a Circle Array, Math, Geometry
- Powerful Integers Math, Enumeration
- Smallest Integer Divisible by K Math, Number Theory
- Fraction to Recurring Decimal Math, String
- Find the Substring With Maximum Cost Array, String, Dynamic Programming
- Make Number of Distinct Characters Equal String, Counting
- Using a Robot to Print the Lexicographically Smallest String String, Stack, Greedy
- Largest Palindromic Number String, Greedy, Counting
- Longest Palindrome by Concatenating Two Letter Words Array, String, Greedy
- Number of Pairs of Strings With Concatenation Equal to Target Array, String, Counting
- Change Minimum Characters to Satisfy One of Three Conditions String, Counting, Prefix Sum
- Split a String Into the Max Number of Unique Substrings String, Backtracking
- Check If a String Contains All Binary Codes of Size K String, Bit Manipulation, Rolling Hash
- Compare Strings by Frequency of the Smallest Character Array, String, Binary Search
- Letter Tile Possibilities String, Backtracking, Counting
- Find And Replace in String Array, String, Sorting
- Subdomain Visit Count Array, String, Counting
- Bulls and Cows String, Counting
- Repeated DNA Sequences String, Sliding Window, Rolling Hash
- Groups of Special-Equivalent Strings Array, String, Sorting
- Sum of Distances Array, Prefix Sum
- Find the Prefix Common Array of Two Arrays Array, Bit Manipulation
- Find Score of an Array After Marking All Elements Array, Sorting, Heap (Priority Queue)
- Count the Number of Beautiful Subarrays Array, Bit Manipulation, Prefix Sum
- Longest Square Streak in an Array Array, Binary Search, Dynamic Programming
- Divide Players Into Teams of Equal Skill Array, Two Pointers, Sorting
- Maximum Sum of Distinct Subarrays With Length K Array, Sliding Window
- Node With Highest Edge Score Graph
- Task Scheduler II Array, Simulation
- Replace Elements in an Array Array, Simulation
- Minimum Rounds to Complete All Tasks Array, Greedy, Counting
- Find All Lonely Numbers in the Array Array, Counting
- Tuple with Same Product Array, Counting
- Count Good Meals Array
- Make Sum Divisible by P Array, Prefix Sum
- Pairs of Songs With Total Durations Divisible by 60 Array, Counting
- Array of Doubled Pairs Array, Greedy, Sorting
- Count Number of Texts Math, String, Dynamic Programming
- Construct String With Repeat Limit String, Greedy, Heap (Priority Queue)
- Minimum Number of Steps to Make Two Strings Anagram II String, Counting
- Count Vowel Substrings of a String String, Sliding Window
- Minimum Length of String After Operations String, Counting
- Sum of Digit Differences of All Pairs Array, Math, Counting
- The Number of the Smallest Unoccupied Chair Array, Heap (Priority Queue), Ordered Set
- Number of Nodes in the Sub-Tree With the Same Label Tree, Graph, Depth-First Search
- Convert an Array Into a 2D Array With Conditions Array, Matrix
- First Completely Painted Row or Column Array, Matrix
- The Number of Beautiful Subsets Array, Dynamic Programming, Backtracking
- Longest Ideal Subsequence String, Dynamic Programming
- Longest Arithmetic Subsequence Array, Dynamic Programming, Binary Search
- Destroy Sequential Targets Array, Counting
- Smallest Missing Non-negative Integer After Operations Array, Math, Greedy
- Minimum Consecutive Cards to Pick Up Array, Sliding Window
- Length of Longest Subarray With at Most K Frequency Array, Sliding Window
- Count Complete Subarrays in an Array Array, Sliding Window
- Count the Number of Good Subarrays Array, Sliding Window, Counting
- Swap For Longest Repeated Character Substring String, Sliding Window, Binary Search
- Number of Substrings Containing All Three Characters String, Sliding Window
- Longest Substring with At Most K Distinct Characters String, Sliding Window
- Longest Substring with At Most Two Distinct Characters String, Sliding Window
- 3Sum With Multiplicity Array, Two Pointers, Counting
- Max Number of K-Sum Pairs Array, Two Pointers, Sorting
- Number of Wonderful Substrings Bit Manipulation, String, Prefix Sum
- Find the Longest Substring Containing Vowels in Even Counts Bit Manipulation, String, Prefix Sum
- Minimum Number of Operations to Make Array Empty Greedy, Counting
- 4Sum II Array, Counting
- Find Players With Zero or One Losses Array, Sorting, Counting
- Minimum Area Rectangle Array, Geometry
- Number of Boomerangs Math, Array
- Group the People Given the Group Size They Belong To Array, Greedy
- Optimal Partition of String String, Greedy
- Count Number of Bad Pairs Array, Counting
- Determine if Two Strings Are Close String, Counting, Sorting
- Equal Row and Column Pairs Matrix, Simulation
- Brick Wall Array, Counting
- Smallest String With Swaps Union Find, String, Sorting
- Number of Pairs of Interchangeable Rectangles Array, Math, Counting
- Count Nice Pairs in an Array Array, Math, Counting
- Maximum Size Subarray Sum Equals k Array, Prefix Sum
- Longest Well-Performing Interval Array, Prefix Sum, Stack
- Subarray Sums Divisible by K Array, Prefix Sum
- Maximum Number of Integers to Choose From a Range I Greedy, Binary Search
- Short Encoding of Words String, Trie
- Replace Words String, Trie
- Longest Word in Dictionary String, Trie
- Word Subsets String, Counting
- Number of Good Ways to Split a String String, Prefix Sum
- Can Convert String in K Moves String, Greedy
- Maximum Number of Occurrences of a Substring String, Sliding Window
- Count Words Obtained After Adding a Letter String, Bit Manipulation
- Find and Replace Pattern String
- Longest Subarray With Sum Zero Array, Prefix Sum
- Find Original Array From Doubled Array Array, Greedy, Sorting
- K-diff Pairs in an Array Array
- Minimum Genetic Mutation String, Breadth-First Search
- Number of Distinct Islands Array, Depth-First Search, Breadth-First Search
- Count Triplets That Can Form Two Arrays of Equal XOR Array, Math, Bit Manipulation
- Maximum XOR of Two Numbers in an Array Array, Bit Manipulation, Trie
- Top K Frequent Words Array, String, Sorting
- Minimum Number of Steps to Make Two Strings Anagram String, Counting
- Minimum Deletions to Make Character Frequencies Unique String, Greedy, Sorting
- Reduce Array Size to The Half Array, Greedy, Sorting
- Longest String Chain Array, Two Pointers, String
- Ugly Number II Math, Dynamic Programming, Heap
- Longest Arithmetic Subsequence of Given Difference Array, Dynamic Programming
- Delete and Earn Array, Dynamic Programming
- Valid Sudoku Array, Matrix
- Count Number of Nice Subarrays Array, Math, Sliding Window
- Binary Subarrays With Sum Array, Sliding Window, Prefix Sum
- Maximum Erasure Value Array, Sliding Window
- Minimum Operations to Reduce X to Zero Array, Binary Search, Sliding Window
- Continuous Subarray Sum Array, Math, Prefix Sum
- Contiguous Array Array, Prefix Sum
- Custom Sort String String, Sorting
- Majority Element II Array, Sorting, Counting
- Find All Duplicates in an Array Array
- Integer to Roman Math, String, Greedy
- Letter Combinations of a Phone Number String, Backtracking
- Set Matrix Zeroes Array, Matrix
- Sort Characters By Frequency String, Heap, Bucket Sort
- Least Number of Unique Integers after K Removals Array, Heap, Greedy
- Top K Frequent Elements Array, Heap, Bucket Sort
- Word Break String, Dynamic Programming, Trie
- Partition Labels String, Greedy, Two Pointers
- Hand of Straights Array, Greedy, Sorting
- Permutation in String String, Sliding Window
- Fruit Into Baskets Array, Sliding Window
- Find All Anagrams in a String String, Sliding Window
- Longest Substring Without Repeating Characters String, Sliding Window
- Longest Consecutive Sequence Array, Union Find
- Subarray Sum Equals K Array, Prefix Sum
Hard (55)
- Design Movie Rental System Array, Heap (Priority Queue), Ordered Set
- Dinner Plate Stacks Stack, Heap (Priority Queue), Design
- Prefix and Suffix Search Array, String, Design
- LFU Cache Linked List, Design
- Vertical Order Traversal of a Binary Tree Tree, Depth-First Search, Breadth-First Search
- Maximum Number of Ways to Partition an Array Array, Counting, Enumeration
- Sum of Imbalance Numbers of All Subarrays Array, Ordered Set
- Maximum Equal Frequency Array, Counting
- Maximum Product of the Length of Two Palindromic Substrings String, Rolling Hash, Dynamic Programming
- Add Edges to Make Degrees of All Nodes Even Graph
- Minimum Number of Flips to Convert Binary Matrix to Zero Matrix Array, Bit Manipulation, Breadth-First Search
- Escape a Large Maze Array, Depth-First Search, Breadth-First Search
- Minimize Malware Spread II Array, Depth-First Search, Breadth-First Search
- Sum of Good Subsequences Array, Dynamic Programming
- Find the Maximum Length of a Good Subsequence II Array, Dynamic Programming
- Count of Sub-Multisets With Bounded Sum Array, Dynamic Programming, Sliding Window
- Maximum Strictly Increasing Cells in a Matrix Array, Binary Search, Dynamic Programming
- Maximum Deletions on a String String, Dynamic Programming, Rolling Hash
- Sudoku Solver Array, Backtracking, Matrix
- Minimize Malware Spread Array, Graph, Union Find
- Similar String Groups Array, String, Union Find
- Arithmetic Slices II - Subsequence Array, Dynamic Programming
- Rearranging Fruits Array, Greedy, Sorting
- Number of Atoms String, Stack, Sorting
- Minimum Operations to Make a Subsequence Array, Binary Search, Greedy
- Count Subarrays With Median K Array, Prefix Sum
- Apply Operations on Array to Maximize Sum of Squares Array, Greedy, Bit Manipulation
- Number of Excellent Pairs Array, Binary Search, Bit Manipulation
- Triples with Bitwise AND Equal To Zero Array, Bit Manipulation
- Perfect Rectangle Array, Math, Geometry
- Word Break II String, Dynamic Programming, Backtracking
- Palindrome Pairs Array, String, Trie
- Distinct Echo Substrings String, Trie, Rolling Hash
- Count Complete Substrings String, Sliding Window
- Length of the Longest Valid Substring Array, String, Sliding Window
- Naming a Company String, Bit Manipulation, Enumeration
- Total Appeal of A String String, Dynamic Programming
- Find Longest Awesome Substring String, Bit Manipulation, Prefix Sum
- Minimum Cost to Split an Array Array, Dynamic Programming, Counting
- Count Anagrams Math, String, Combinatorics
- Smallest Range Covering Elements from K Lists Array, Greedy, Sliding Window
- Minimum Number of Operations to Make Array Continuous Array, Binary Search, Sliding Window
- Bus Routes Array, Breadth-First Search
- Jump Game IV Array, Breadth-First Search
- Grid Illumination Array, Matrix
- Number of Submatrices That Sum to Target Array, Matrix, Prefix Sum
- Frog Jump Array, Dynamic Programming
- Take K of Each Character From Left and Right String, Sliding Window, Prefix Sum
- Subarrays with K Different Integers Array, Sliding Window, Two Pointers
- Substring with Concatenation of All Words String, Sliding Window
- Max Points on a Line Math, Geometry
- Count Unique Characters of All Substrings of a Given String String, Counting
- Word Ladder String, Breadth-First Search
- Minimum Window Substring String, Sliding Window
- First Missing Positive Array
Companies that ask hash table problems
- Amazon 368 problems on hash table
- Google 268 problems on hash table
- Microsoft 53 problems on hash table
- Meta 37 problems on hash table
- Adobe 35 problems on hash table
- TCS 25 problems on hash table
- Infosys 23 problems on hash table
- Bloomberg 19 problems on hash table
- Uber 15 problems on hash table
- Flipkart 12 problems on hash table
- Atlassian 9 problems on hash table
- Snapchat 9 problems on hash table
Next topic: Counting