Hash Table LeetCode Problems: All 588,
With Python Solutions

Every problem in this library that LeetCode tags Hash Table. 492 of them carry a complete Python solution, a worked example and the time and space complexity of the approach.

Easy
143
Medium
347
Hard
98
1 pattern

How Hash Table problems are solved

A tag names the subject, not the method. These pattern hubs cover the techniques that actually solve Hash Table problems — each one explains the approach, gives a Python template and states its complexity.

Eyes only

When the Hash Table problem arrives live.

In the live round, Stealth Interview reads the problem off your screen, returns a working solution with a step-by-step explanation and its time and space complexity, and transcribes what the interviewer says. It's a desktop app for macOS and Windows, invisible to screen sharing.

Hash Table problems by difficulty

Showing the first 200 of 588 problems. Problems with a complete Python solution are listed first, then by ascending problem number.

Easy (47)

Easy problems
No.Problem
0001Two Sum
0013Roman to Integer
0141Linked List Cycle
0160Intersection of Two Linked Lists
0169Majority Element
0202Happy Number
0205Isomorphic Strings
0217Contains Duplicate
0219Contains Duplicate II
0242Valid Anagram
0268Missing Number
0290Word Pattern
0349Intersection of Two Arrays
0350Intersection of Two Arrays II
0383Ransom Note
0387First Unique Character in a String
0389Find the Difference
0409Longest Palindrome
0448Find All Numbers Disappeared in an Array
0496Next Greater Element I
0500Keyboard Row
0575Distribute Candies
0594Longest Harmonious Subsequence
0599Minimum Index Sum of Two Lists
0645Set Mismatch
0653Two Sum IV - Input is a BST
0697Degree of an Array
0705Design HashSet
0706Design HashMap
0748Shortest Completing Word
0771Jewels and Stones
0804Unique Morse Code Words
0819Most Common Word
0859Buddy Strings
0884Uncommon Words from Two Sentences
0888Fair Candy Swap
0914X of a Kind in a Deck of Cards
0929Unique Email Addresses
0953Verifying an Alien Dictionary
0961N-Repeated Element in Size 2N Array
0997Find the Town Judge
1002Find Common Characters
1122Relative Sort Array
1128Number of Equivalent Domino Pairs
1160Find Words That Can Be Formed by Characters
1189Maximum Number of Balloons
1207Unique Number of Occurrences

Medium (115)

Medium problems
No.Problem
0003Longest Substring Without Repeating Characters
0012Integer to Roman
0017Letter Combinations of a Phone Number
0036Valid Sudoku
0049Group Anagrams
0073Set Matrix Zeroes
0105Construct Binary Tree from Preorder and Inorder Traversal
0106Construct Binary Tree from Inorder and Postorder Traversal
0128Longest Consecutive Sequence
0133Clone Graph
0138Copy List with Random Pointer
0139Word Break
0142Linked List Cycle II
0146LRU Cache
0166Fraction to Recurring Decimal
0187Repeated DNA Sequences
0208Implement Trie (Prefix Tree)
0229Majority Element II
0264Ugly Number II
0299Bulls and Cows
0347Top K Frequent Elements
0355Design Twitter
0380Insert Delete GetRandom O(1)
0395Longest Substring with At Least K Repeating Characters
0398Random Pick Index
0421Maximum XOR of Two Numbers in an Array
0423Reconstruct Original Digits from English
0424Longest Repeating Character Replacement
0433Minimum Genetic Mutation
0438Find All Anagrams in a String
0442Find All Duplicates in an Array
0447Number of Boomerangs
0451Sort Characters By Frequency
04544Sum II
0457Circular Array Loop
0491Non-decreasing Subsequences
0508Most Frequent Subtree Sum
0519Random Flip Matrix
0522Longest Uncommon Subsequence II
0523Continuous Subarray Sum
0525Contiguous Array
0532K-diff Pairs in an Array
0535Encode and Decode TinyURL
0554Brick Wall
0560Subarray Sum Equals K
0567Permutation in String
0609Find Duplicate File in System
0621Task Scheduler
0648Replace Words
0652Find Duplicate Subtrees
0659Split Array into Consecutive Subsequences
0676Implement Magic Dictionary
0677Map Sum Pairs
0690Employee Importance
0692Top K Frequent Words
0720Longest Word in Dictionary
0721Accounts Merge
0740Delete and Earn
0752Open the Lock
0756Pyramid Transition Matrix
0763Partition Labels
0767Reorganize String
0781Rabbits in Forest
0791Custom Sort String
0792Number of Matching Subsequences
0811Subdomain Visit Count
0817Linked List Components
0820Short Encoding of Words
0822Card Flipping Game
0823Binary Trees With Factors
0833Find And Replace in String
0840Magic Squares In Grid
0846Hand of Straights
0863All Nodes Distance K in Binary Tree
0865Smallest Subtree with all the Deepest Nodes
0869Reordered Power of 2
0873Length of Longest Fibonacci Subsequence
0874Walking Robot Simulation
0889Construct Binary Tree from Preorder and Postorder Traversal
0890Find and Replace Pattern
0893Groups of Special-Equivalent Strings
0904Fruit Into Baskets
0911Online Election
0916Word Subsets
09233Sum With Multiplicity
0930Binary Subarrays With Sum
0939Minimum Area Rectangle
0947Most Stones Removed with Same Row or Column
0954Array of Doubled Pairs
0959Regions Cut By Slashes
0963Minimum Area Rectangle II
0966Vowel Spellchecker
0970Powerful Integers
0974Subarray Sums Divisible by K
0981Time Based Key-Value Store
1010Pairs of Songs With Total Durations Divisible by 60
1015Smallest Integer Divisible by K
1016Binary String With Substrings Representing 1 To N
1027Longest Arithmetic Subsequence
1048Longest String Chain
1054Distant Barcodes
1072Flip Columns For Maximum Number of Equal Rows
1079Letter Tile Possibilities
1090Largest Values From Labels
1110Delete Nodes And Return Forest
1123Lowest Common Ancestor of Deepest Leaves
1124Longest Well-Performing Interval
1138Alphabet Board Path
1146Snapshot Array
1156Swap For Longest Repeated Character Substring
1169Invalid Transactions
1170Compare Strings by Frequency of the Smallest Character
1171Remove Zero Sum Consecutive Nodes from Linked List
1177Can Make Palindrome from Substring
1202Smallest String With Swaps

Hard (38)

Hard problems
No.Problem
0030Substring with Concatenation of All Words
0037Sudoku Solver
0041First Missing Positive
0076Minimum Window Substring
0126Word Ladder II
0127Word Ladder
0140Word Break II
0149Max Points on a Line
0336Palindrome Pairs
0352Data Stream as Disjoint Intervals
0381Insert Delete GetRandom O(1) - Duplicates allowed
0391Perfect Rectangle
0432All O`one Data Structure
0460LFU Cache
0480Sliding Window Median
0632Smallest Range Covering Elements from K Lists
0691Stickers to Spell Word
0710Random Pick with Blacklist
0736Parse Lisp Expression
0745Prefix and Suffix Search
0815Bus Routes
0828Count Unique Characters of All Substrings of a Given String
0839Similar String Groups
0854K-Similar Strings
0895Maximum Frequency Stack
0924Minimize Malware Spread
0928Minimize Malware Spread II
0952Largest Component Size by Common Factor
0982Triples with Bitwise AND Equal To Zero
0987Vertical Order Traversal of a Binary Tree
0992Subarrays with K Different Integers
0996Number of Squareful Arrays
1001Grid Illumination
1036Escape a Large Maze
1074Number of Submatrices That Sum to Target
1096Brace Expansion II
1172Dinner Plate Stacks
1178Number of Valid Words for Each Puzzle