Basic Hash Table Problems for Coding Interviews
69 basic Hash Table problems from real coding interviews, each with test cases you can run online. By difficulty they split into 69 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Google, Amazon, Bloomberg, Meta.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Contains Duplicate (Basic)
- Climbing Stairs (Basic)
- First Unique Character (Basic)
- Missing Number (Basic)
- Intersection of Two Arrays (Basic)
- Count Distinct Values (Basic)
- Valid Anagram (Basic)
- Remove Duplicates Keeping Order (Basic)
- Third Maximum Number (Basic)
- Sum of Unique Values (Basic)
- Kth Missing Positive Number (Basic)
- Find the Duplicate and Missing Number (Basic)
- Unique Number of Occurrences (Basic)
- Remove Adjacent Duplicate Letters (Basic)
- Count Unique Binary Search Trees (Basic)
- Maximum Frequency After Increments (Basic)
- Tree Distance Queries (Basic)
- BST Range Sum (Basic)
- Count Distinct Islands Shapes (Basic)
- Find Duplicate Subtrees (Basic)
- Maximum Path Quality (Basic)
- Maximum Sum Path Across Two Arrays (Basic)
- Element Frequencies in a Linked List (Basic)
- Minimum Absolute Difference in BST (Basic)
- Two Sum in a BST (Basic)
- Insert Into a BST (Basic)
- Cousins in Binary Tree (Basic)
- Closest Value in a BST (Basic)
- Minimum Vertices to Reach All Nodes (Basic)
- Custom Sort String (Basic)
- Minimum Steps to Make Two Strings Anagram (Basic)
- Partition String Into Unique Substrings (Basic)
- Relative Sort Array (Basic)
- Design HashMap (Basic)
- Find the Difference of Two Arrays (Basic)
- Largest Triangle Area (Basic)
- Count the Number of Consistent Strings (Basic)
- Second Largest Digit in a String (Basic)
- Zigzag Linked List (Basic)
- Sorted Union of Two Lists (Basic)
- Sorted Intersection of Two Lists (Basic)
- Second Minimum Node in a Binary Tree (Basic)
- Count Anagram Groups (Basic)
- Most Common Word (Basic)
- Unique Morse Code Words (Basic)
- Jewels and Stones (Basic)
- String Matching in an Array (Basic)
- Duplicate Zeros (Basic)
- Lucky Numbers in a Matrix (Basic)
- Minimum Index Sum of Two Lists (Basic)
- Fixed Point (Basic)
- Distinct Integers After Reverse Operations (Basic)
- Find the Pivot Integer (Basic)
- Sort Array by Increasing Frequency (Basic)
- Stair Climbing With Steps One Two or Three (Basic)
- Count Distinct Rows in Matrix (Basic)
- Count Distinct Substrings of Length K (Basic)
- Number of Anagram Groups in Sentence (Basic)
- Robot Path Distinct Cells Visited (Basic)
- Distinct Absolute Values in Sorted Array (Basic)
- Mobius Function Value (Basic)
- Radical of an Integer (Basic)
- Most Distinct Letters in a Word (Basic)
- Distinct Words Ignoring Case (Basic)
- Second Smallest Distinct Value (Basic)
- Most Distinct Values in a Row (Basic)
- Remove Duplicates Keep Last (Basic)
- Distinct Absolute Values (Basic)
- Second Highest Frequency (Basic)
Related
Frequently asked questions
How do I get good at hash table problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run hash table problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.