Hash Map Pattern: Template + 709 LeetCode Problems
Trade memory for time: remember what you have seen so the second pass never happens.
- 227 Easy
- 372 Medium
- 110 Hard
- O(1) average per operation, O(n) worst case time
What the hash map pattern is
A hash map converts a search into a lookup, which is why it is the most common single answer in this entire corpus — 588 of the 3000 problems are built on one. Three uses cover nearly all of them. The complement lookup asks, at each element, whether the thing that would complete the answer has already been seen: storing values as you go turns two nested loops into one pass, and the reason it works is that a pair is found from its second member, so only the past needs to be remembered. Frequency counting answers anagram, majority and top-k questions by comparing counts instead of arrangements. Grouping needs a canonical key — a sorted string, a character-count tuple, a normalised pattern — chosen so that two inputs collide exactly when they belong together, and that choice is the whole problem. Python's dict preserves insertion order, so an ordered result often needs no extra bookkeeping.
When to use it
- The brute force is a nested loop asking "is there another element such that…".
- You are counting occurrences, or comparing two multisets.
- Items must be grouped by a property you can compute into a stable key.
- Membership must be tested repeatedly and the input is not sorted.
- Seen-before state has to survive across a single pass — de-duplication, cycle detection on values.
The hash map template in Python
The shape, not a solution to any one problem. Adapt the condition and the summary being maintained; the skeleton stays the same across the 709 problems listed below.
def two_sum(nums, target):
seen = {} # value -> the index it was found at
for i, value in enumerate(nums):
if target - value in seen: # the partner was already scanned
return [seen[target - value], i]
seen[value] = i
return []Complexity characteristics
- Time
- O(1) average per operation, O(n) worst case
- Auxiliary space
- O(n)
Average-case constant lookups are what turn a nested-loop search into a single pass, so the complement and frequency-counting solutions are O(n) time and O(n) space. The worst case is linear per operation when every key collides, which is irrelevant on real data and is the reason a language's string hash is randomised per process. Ordering is not free: getting a sorted result out of a map costs the sort on top.
All 709 hash map LeetCode problems
Every problem in the library the hash map pattern applies to, grouped by LeetCode's own difficulty rating. 601 of the 709 carry a complete Python solution with a worked example and complexity analysis; the rest are listed for completeness, with the LeetCode Premium ones marked.
Easy (227)
Medium (372)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 3 | Longest Substring Without Repeating Characters | Medium | Hash Table, String, Sliding Window |
| 6 | Zigzag Conversion | Medium | String |
| 8 | String to Integer (atoi) | Medium | String |
| 12 | Integer to Roman | Medium | Hash Table, Math, String |
| 17 | Letter Combinations of a Phone Number | Medium | Hash Table, String, Backtracking |
| 36 | Valid Sudoku | Medium | Array, Hash Table, Matrix |
| 38 | Count and Say | Medium | String |
| 49 | Group Anagrams | Medium | Array, Hash Table, String +1 |
| 73 | Set Matrix Zeroes | Medium | Array, Hash Table, Matrix |
| 105 | Construct Binary Tree from Preorder and Inorder Traversal | Medium | Tree, Array, Hash Table +2 |
| 106 | Construct Binary Tree from Inorder and Postorder Traversal | Medium | Tree, Array, Hash Table +2 |
| 128 | Longest Consecutive Sequence | Medium | Union Find, Array, Hash Table |
| 133 | Clone Graph | Medium | Depth-First Search, Breadth-First Search, Graph +1 |
| 138 | Copy List with Random Pointer | Medium | Hash Table, Linked List |
| 139 | Word Break | Medium | Trie, Memoization, Array +3 |
| 142 | Linked List Cycle II | Medium | Hash Table, Linked List, Two Pointers |
| 146 | LRU Cache | Medium | Design, Hash Table, Linked List +1 |
| 166 | Fraction to Recurring Decimal | Medium | Hash Table, Math, String |
| 187 | Repeated DNA Sequences | Medium | Bit Manipulation, Hash Table, String +3 |
| 208 | Implement Trie (Prefix Tree) | Medium | Design, Trie, Hash Table +1 |
| 229 | Majority Element II | Medium | Array, Hash Table, Counting +1 |
| 264 | Ugly Number II | Medium | Hash Table, Math, Dynamic Programming +1 |
| 299 | Bulls and Cows | Medium | Hash Table, String, Counting |
| 347 | Top K Frequent Elements | Medium | Array, Hash Table, Divide and Conquer +5 |
| 355 | Design Twitter | Medium | Design, Hash Table, Linked List +1 |
| 380 | Insert Delete GetRandom O(1) | Medium | Design, Array, Hash Table +2 |
| 395 | Longest Substring with At Least K Repeating Characters | Medium | Hash Table, String, Divide and Conquer +1 |
| 398 | Random Pick Index | Medium | Reservoir Sampling, Hash Table, Math +1 |
| 421 | Maximum XOR of Two Numbers in an Array | Medium | Bit Manipulation, Trie, Array +1 |
| 423 | Reconstruct Original Digits from English | Medium | Hash Table, Math, String |
| 424 | Longest Repeating Character Replacement | Medium | Hash Table, String, Sliding Window |
| 433 | Minimum Genetic Mutation | Medium | Breadth-First Search, Hash Table, String |
| 438 | Find All Anagrams in a String | Medium | Hash Table, String, Sliding Window |
| 442 | Find All Duplicates in an Array | Medium | Array, Hash Table, Sorting |
| 447 | Number of Boomerangs | Medium | Array, Hash Table, Math |
| 451 | Sort Characters By Frequency | Medium | Hash Table, String, Bucket Sort +3 |
| 454 | 4Sum II | Medium | Array, Hash Table |
| 457 | Circular Array Loop | Medium | Array, Hash Table, Two Pointers |
| 468 | Validate IP Address | Medium | String |
| 491 | Non-decreasing Subsequences | Medium | Bit Manipulation, Array, Hash Table +1 |
| 508 | Most Frequent Subtree Sum | Medium | Tree, Depth-First Search, Hash Table +1 |
| 519 | Random Flip Matrix | Medium | Reservoir Sampling, Hash Table, Math +1 |
| 522 | Longest Uncommon Subsequence II | Medium | Array, Hash Table, Two Pointers +2 |
| 523 | Continuous Subarray Sum | Medium | Array, Hash Table, Math +1 |
| 525 | Contiguous Array | Medium | Array, Hash Table, Prefix Sum |
| 532 | K-diff Pairs in an Array | Medium | Array, Hash Table, Two Pointers +2 |
| 535 | Encode and Decode TinyURL | Medium | Design, Hash Table, String +1 |
| 554 | Brick Wall | Medium | Array, Hash Table |
| 560 | Subarray Sum Equals K | Medium | Array, Hash Table, Prefix Sum |
| 567 | Permutation in String | Medium | Hash Table, Two Pointers, String +1 |
| 609 | Find Duplicate File in System | Medium | Array, Hash Table, String |
| 621 | Task Scheduler | Medium | Greedy, Array, Hash Table +3 |
| 648 | Replace Words | Medium | Trie, Array, Hash Table +1 |
| 652 | Find Duplicate Subtrees | Medium | Tree, Depth-First Search, Hash Table +1 |
| 659 | Split Array into Consecutive Subsequences | Medium | Greedy, Array, Hash Table +1 |
| 676 | Implement Magic Dictionary | Medium | Depth-First Search, Design, Trie +2 |
| 677 | Map Sum Pairs | Medium | Design, Trie, Hash Table +1 |
| 686 | Repeated String Match | Medium | String, String Matching |
| 690 | Employee Importance | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 692 | Top K Frequent Words | Medium | Trie, Array, Hash Table +5 |
| 720 | Longest Word in Dictionary | Medium | Trie, Array, Hash Table +2 |
| 721 | Accounts Merge | Medium | Depth-First Search, Breadth-First Search, Union Find +4 |
| 722 | Remove Comments | Medium | Array, String |
| 740 | Delete and Earn | Medium | Array, Hash Table, Dynamic Programming |
| 763 | Partition Labels | Medium | Greedy, Hash Table, Two Pointers +1 |
| 846 | Hand of Straights | Medium | Greedy, Array, Hash Table +1 |
| 981 | Time Based Key-Value Store | Medium | Design, Hash Table, String +1 |
| 1657 | Determine if Two Strings Are Close | Medium | Hash Table, String, Counting +1 |
| 1679 | Max Number of K-Sum Pairs | Medium | Array, Hash Table, Two Pointers +1 |
| 2013 | Detect Squares | Medium | Design, Array, Hash Table +1 |
| 2336 | Smallest Number in Infinite Set | Medium | Design, Hash Table, Ordered Set +1 |
| 2352 | Equal Row and Column Pairs | Medium | Array, Hash Table, Matrix +1 |
| 159 | Longest Substring with At Most Two Distinct CharactersPremium | Medium | Hash Table, String, Sliding Window |
| 244 | Shortest Word Distance IIPremium | Medium | Design, Array, Hash Table +2 |
| 245 | Shortest Word Distance IIIPremium | Medium | Array, String |
| 247 | Strobogrammatic Number IIPremium | Medium | Recursion, Array, String |
| 249 | Group Shifted StringsPremium | Medium | Array, Hash Table, String |
| 267 | Palindrome Permutation IIPremium | Medium | Hash Table, String, Backtracking |
| 271 | Encode and Decode StringsPremium | Medium | Design, Array, String |
| 288 | Unique Word AbbreviationPremium | Medium | Design, Array, Hash Table +1 |
| 291 | Word Pattern IIPremium | Medium | Hash Table, String, Backtracking |
| 311 | Sparse Matrix MultiplicationPremium | Medium | Array, Hash Table, Matrix |
| 314 | Binary Tree Vertical Order TraversalPremium | Medium | Tree, Depth-First Search, Breadth-First Search +3 |
| 325 | Maximum Size Subarray Sum Equals kPremium | Medium | Array, Hash Table, Prefix Sum |
| 340 | Longest Substring with At Most K Distinct CharactersPremium | Medium | Hash Table, String, Sliding Window |
| 348 | Design Tic-Tac-ToePremium | Medium | Design, Array, Hash Table +2 |
| 353 | Design Snake GamePremium | Medium | Design, Queue, Array +2 |
| 356 | Line ReflectionPremium | Medium | Array, Hash Table, Math |
| 379 | Design Phone DirectoryPremium | Medium | Design, Queue, Array +2 |
| 531 | Lonely Pixel IPremium | Medium | Array, Hash Table, Matrix |
| 533 | Lonely Pixel IIPremium | Medium | Array, Hash Table, Matrix |
| 544 | Output Contest MatchesPremium | Medium | Recursion, String, Simulation |
| 582 | Kill ProcessPremium | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 616 | Add Bold Tag in StringPremium | Medium | Trie, Array, Hash Table +2 |
| 635 | Design Log Storage SystemPremium | Medium | Design, Hash Table, String +1 |
| 666 | Path Sum IVPremium | Medium | Tree, Depth-First Search, Array +2 |
| 681 | Next Closest TimePremium | Medium | Hash Table, String, Backtracking +1 |
| 694 | Number of Distinct IslandsPremium | Medium | Depth-First Search, Breadth-First Search, Union Find +2 |
| 737 | Sentence Similarity IIPremium | Medium | Depth-First Search, Breadth-First Search, Union Find +3 |
| 752 | Open the Lock | Medium | Breadth-First Search, Array, Hash Table +1 |
| 756 | Pyramid Transition Matrix | Medium | Bit Manipulation, Hash Table, String +1 |
| 758 | Bold Words in StringPremium | Medium | Trie, Array, Hash Table +2 |
| 767 | Reorganize String | Medium | Greedy, Hash Table, String +3 |
| 781 | Rabbits in Forest | Medium | Greedy, Array, Hash Table +1 |
| 791 | Custom Sort String | Medium | Hash Table, String, Sorting |
| 792 | Number of Matching Subsequences | Medium | Trie, Array, Hash Table +4 |
| 811 | Subdomain Visit Count | Medium | Array, Hash Table, String +1 |
| 817 | Linked List Components | Medium | Array, Hash Table, Linked List |
| 820 | Short Encoding of Words | Medium | Trie, Array, Hash Table +1 |
| 822 | Card Flipping Game | Medium | Array, Hash Table |
| 823 | Binary Trees With Factors | Medium | Array, Hash Table, Dynamic Programming +1 |
| 831 | Masking Personal Information | Medium | String |
| 833 | Find And Replace in String | Medium | Array, Hash Table, String +1 |
| 840 | Magic Squares In Grid | Medium | Array, Hash Table, Math +1 |
| 863 | All Nodes Distance K in Binary Tree | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 865 | Smallest Subtree with all the Deepest Nodes | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 869 | Reordered Power of 2 | Medium | Hash Table, Math, Counting +2 |
| 873 | Length of Longest Fibonacci Subsequence | Medium | Array, Hash Table, Dynamic Programming |
| 874 | Walking Robot Simulation | Medium | Array, Hash Table, Simulation |
| 889 | Construct Binary Tree from Preorder and Postorder Traversal | Medium | Tree, Array, Hash Table +2 |
| 890 | Find and Replace Pattern | Medium | Array, Hash Table, String |
| 893 | Groups of Special-Equivalent Strings | Medium | Array, Hash Table, String +1 |
| 900 | RLE Iterator | Medium | Design, Array, Counting +1 |
| 904 | Fruit Into Baskets | Medium | Array, Hash Table, Sliding Window |
| 911 | Online Election | Medium | Design, Array, Hash Table +1 |
| 916 | Word Subsets | Medium | Array, Hash Table, String |
| 923 | 3Sum With Multiplicity | Medium | Array, Hash Table, Two Pointers +2 |
| 930 | Binary Subarrays With Sum | Medium | Array, Hash Table, Prefix Sum +1 |
| 939 | Minimum Area Rectangle | Medium | Geometry, Array, Hash Table +2 |
| 945 | Minimum Increment to Make Array Unique | Medium | Greedy, Array, Counting +1 |
| 947 | Most Stones Removed with Same Row or Column | Medium | Depth-First Search, Union Find, Graph +1 |
| 954 | Array of Doubled Pairs | Medium | Greedy, Array, Hash Table +1 |
| 957 | Prison Cells After N Days | Medium | Bit Manipulation, Array, Hash Table +1 |
| 959 | Regions Cut By Slashes | Medium | Depth-First Search, Breadth-First Search, Union Find +3 |
| 963 | Minimum Area Rectangle II | Medium | Geometry, Array, Hash Table +1 |
| 966 | Vowel Spellchecker | Medium | Array, Hash Table, String |
| 970 | Powerful Integers | Medium | Hash Table, Math, Enumeration |
| 974 | Subarray Sums Divisible by K | Medium | Array, Hash Table, Prefix Sum |
| 1010 | Pairs of Songs With Total Durations Divisible by 60 | Medium | Array, Hash Table, Counting |
| 1015 | Smallest Integer Divisible by K | Medium | Hash Table, Math |
| 1016 | Binary String With Substrings Representing 1 To N | Medium | Bit Manipulation, Hash Table, String +1 |
| 1027 | Longest Arithmetic Subsequence | Medium | Array, Hash Table, Binary Search +1 |
| 1048 | Longest String Chain | Medium | Array, Hash Table, Two Pointers +3 |
| 1054 | Distant Barcodes | Medium | Greedy, Array, Hash Table +3 |
| 1072 | Flip Columns For Maximum Number of Equal Rows | Medium | Array, Hash Table, Matrix |
| 1079 | Letter Tile Possibilities | Medium | Hash Table, String, Backtracking +1 |
| 1090 | Largest Values From Labels | Medium | Greedy, Array, Hash Table +2 |
| 1100 | Find K-Length Substrings With No Repeated CharactersPremium | Medium | Hash Table, String, Sliding Window |
| 1110 | Delete Nodes And Return Forest | Medium | Tree, Depth-First Search, Array +2 |
| 1123 | Lowest Common Ancestor of Deepest Leaves | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 1124 | Longest Well-Performing Interval | Medium | Stack, Array, Hash Table +2 |
| 1138 | Alphabet Board Path | Medium | Hash Table, String |
| 1146 | Snapshot Array | Medium | Design, Array, Hash Table +1 |
| 1152 | Analyze User Website Visit PatternPremium | Medium | Array, Hash Table, String +1 |
| 1156 | Swap For Longest Repeated Character Substring | Medium | Hash Table, String, Sliding Window |
| 1166 | Design File SystemPremium | Medium | Design, Trie, Hash Table +1 |
| 1169 | Invalid Transactions | Medium | Array, Hash Table, String +1 |
| 1170 | Compare Strings by Frequency of the Smallest Character | Medium | Array, Hash Table, String +2 |
| 1171 | Remove Zero Sum Consecutive Nodes from Linked List | Medium | Hash Table, Linked List |
| 1177 | Can Make Palindrome from Substring | Medium | Bit Manipulation, Array, Hash Table +2 |
| 1181 | Before and After PuzzlePremium | Medium | Array, Hash Table, String +1 |
| 1198 | Find Smallest Common Element in All RowsPremium | Medium | Array, Hash Table, Binary Search +2 |
| 1202 | Smallest String With Swaps | Medium | Depth-First Search, Breadth-First Search, Union Find +4 |
| 1218 | Longest Arithmetic Subsequence of Given Difference | Medium | Array, Hash Table, Dynamic Programming |
| 1244 | Design A LeaderboardPremium | Medium | Design, Hash Table, Sorting |
| 1248 | Count Number of Nice Subarrays | Medium | Array, Hash Table, Math +2 |
| 1257 | Smallest Common RegionPremium | Medium | Tree, Depth-First Search, Breadth-First Search +3 |
| 1258 | Synonymous SentencesPremium | Medium | Sort, Union Find, Array +3 |
| 1261 | Find Elements in a Contaminated Binary Tree | Medium | Tree, Depth-First Search, Breadth-First Search +3 |
| 1267 | Count Servers that Communicate | Medium | Depth-First Search, Breadth-First Search, Union Find +3 |
| 1282 | Group the People Given the Group Size They Belong To | Medium | Greedy, Array, Hash Table |
| 1296 | Divide Array in Sets of K Consecutive Numbers | Medium | Greedy, Array, Hash Table +1 |
| 1297 | Maximum Number of Occurrences of a Substring | Medium | Hash Table, String, Sliding Window |
| 1311 | Get Watched Videos by Your Friends | Medium | Breadth-First Search, Graph, Array +2 |
| 1324 | Print Words Vertically | Medium | Array, String, Simulation |
| 1338 | Reduce Array Size to The Half | Medium | Greedy, Array, Hash Table +2 |
| 1347 | Minimum Number of Steps to Make Two Strings Anagram | Medium | Hash Table, String, Counting |
| 1348 | Tweet Counts Per Frequency | Medium | Design, Hash Table, String +3 |
| 1357 | Apply Discount Every n Orders | Medium | Design, Array, Hash Table |
| 1358 | Number of Substrings Containing All Three Characters | Medium | Hash Table, String, Sliding Window |
| 1366 | Rank Teams by Votes | Medium | Array, Hash Table, String +2 |
| 1371 | Find the Longest Substring Containing Vowels in Even Counts | Medium | Bit Manipulation, Hash Table, String +1 |
| 1386 | Cinema Seat Allocation | Medium | Greedy, Bit Manipulation, Array +1 |
| 1396 | Design Underground System | Medium | Design, Hash Table, String |
| 1400 | Construct K Palindrome Strings | Medium | Greedy, Hash Table, String +1 |
| 1410 | HTML Entity Parser | Medium | Hash Table, String |
| 1418 | Display Table of Food Orders in a Restaurant | Medium | Array, Hash Table, String +2 |
| 1419 | Minimum Number of Frogs Croaking | Medium | String, Counting |
| 1429 | First Unique NumberPremium | Medium | Design, Queue, Array +2 |
| 1442 | Count Triplets That Can Form Two Arrays of Equal XOR | Medium | Bit Manipulation, Array, Hash Table +2 |
| 1443 | Minimum Time to Collect All Apples in a Tree | Medium | Tree, Depth-First Search, Breadth-First Search +1 |
| 1452 | People Whose List of Favorite Companies Is Not a Subset of Another List | Medium | Array, Hash Table, String |
| 1461 | Check If a String Contains All Binary Codes of Size K | Medium | Bit Manipulation, Hash Table, String +2 |
| 1477 | Find Two Non-overlapping Sub-arrays Each With Target Sum | Medium | Array, Hash Table, Binary Search +2 |
| 1481 | Least Number of Unique Integers after K Removals | Medium | Greedy, Array, Hash Table +2 |
| 1485 | Clone Binary Tree With Random PointerPremium | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 1487 | Making File Names Unique | Medium | Array, Hash Table, String |
| 1488 | Avoid Flood in The City | Medium | Greedy, Array, Hash Table +2 |
| 1490 | Clone N-ary TreePremium | Medium | Tree, Depth-First Search, Breadth-First Search +1 |
| 1497 | Check If Array Pairs Are Divisible by k | Medium | Array, Hash Table, Counting |
| 1500 | Design a File Sharing SystemPremium | Medium | Design, Hash Table, Data Stream +2 |
| 1506 | Find Root of N-Ary TreePremium | Medium | Bit Manipulation, Tree, Depth-First Search +1 |
| 1519 | Number of Nodes in the Sub-Tree With the Same Label | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 1525 | Number of Good Ways to Split a String | Medium | Bit Manipulation, Hash Table, String +1 |
| 1540 | Can Convert String in K Moves | Medium | Hash Table, String |
| 1545 | Find Kth Bit in Nth Binary String | Medium | Recursion, String, Simulation |
| 1546 | Maximum Number of Non-Overlapping Subarrays With Sum Equals Target | Medium | Greedy, Array, Hash Table +1 |
| 1554 | Strings Differ by One CharacterPremium | Medium | Hash Table, String, Hash Function +1 |
| 1562 | Find Latest Group of Size M | Medium | Array, Hash Table, Binary Search +1 |
| 1570 | Dot Product of Two Sparse VectorsPremium | Medium | Design, Array, Hash Table +1 |
| 1577 | Number of Ways Where Square of Number Is Equal to Product of Two Numbers | Medium | Array, Hash Table, Math +1 |
| 1590 | Make Sum Divisible by P | Medium | Array, Hash Table, Prefix Sum |
| 1593 | Split a String Into the Max Number of Unique Substrings | Medium | Hash Table, String, Backtracking |
| 1600 | Throne Inheritance | Medium | Tree, Depth-First Search, Design +1 |
| 1604 | Alert Using Same Key-Card Three or More Times in a One Hour Period | Medium | Array, Hash Table, String +1 |
| 1612 | Check If Two Expression Trees are EquivalentPremium | Medium | Tree, Depth-First Search, Hash Table +2 |
| 1630 | Arithmetic Subarrays | Medium | Array, Hash Table, Sorting |
| 1638 | Count Substrings That Differ by One Character | Medium | Hash Table, String, Dynamic Programming +1 |
| 1647 | Minimum Deletions to Make Character Frequencies Unique | Medium | Greedy, Hash Table, String +1 |
| 1650 | Lowest Common Ancestor of a Binary Tree IIIPremium | Medium | Tree, Hash Table, Two Pointers +1 |
| 1658 | Minimum Operations to Reduce X to Zero | Medium | Array, Hash Table, Binary Search +2 |
| 1660 | Correct a Binary TreePremium | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 1674 | Minimum Moves to Make Array Complementary | Medium | Array, Hash Table, Prefix Sum |
| 1676 | Lowest Common Ancestor of a Binary Tree IVPremium | Medium | Tree, Depth-First Search, Hash Table +1 |
| 1695 | Maximum Erasure Value | Medium | Array, Hash Table, Sliding Window |
| 1711 | Count Good Meals | Medium | Array, Hash Table |
| 1726 | Tuple with Same Product | Medium | Array, Hash Table, Counting |
| 1733 | Minimum Number of People to Teach | Medium | Greedy, Array, Hash Table |
| 1737 | Change Minimum Characters to Satisfy One of Three Conditions | Medium | Hash Table, String, Counting +1 |
| 1740 | Find Distance in a Binary TreePremium | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 1743 | Restore the Array From Adjacent Pairs | Medium | Depth-First Search, Array, Hash Table |
| 1772 | Sort Features by PopularityPremium | Medium | Array, Hash Table, String +1 |
| 1775 | Equal Sum Arrays With Minimum Number of Operations | Medium | Greedy, Array, Hash Table +1 |
| 1781 | Sum of Beauty of All Substrings | Medium | Hash Table, String, Counting |
| 1794 | Count Pairs of Equal Substrings With Minimum DifferencePremium | Medium | Greedy, Hash Table, String |
| 1797 | Design Authentication Manager | Medium | Design, Hash Table, Linked List +1 |
| 1804 | Implement Trie II (Prefix Tree)Premium | Medium | Design, Trie, Hash Table +1 |
| 1807 | Evaluate the Bracket Pairs of a String | Medium | Array, Hash Table, String |
| 1814 | Count Nice Pairs in an Array | Medium | Array, Hash Table, Math +1 |
| 1817 | Finding the Users Active Minutes | Medium | Array, Hash Table |
| 1836 | Remove Duplicates From an Unsorted Linked ListPremium | Medium | Hash Table, Linked List |
| 1852 | Distinct Numbers in Each SubarrayPremium | Medium | Array, Hash Table, Sliding Window |
| 1865 | Finding Pairs With a Certain Sum | Medium | Design, Array, Hash Table |
| 1906 | Minimum Absolute Difference Queries | Medium | Array, Hash Table |
| 1915 | Number of Wonderful Substrings | Medium | Bit Manipulation, Hash Table, String +1 |
| 1930 | Unique Length-3 Palindromic Subsequences | Medium | Bit Manipulation, Hash Table, String +1 |
| 1940 | Longest Common Subsequence Between Sorted ArraysPremium | Medium | Array, Hash Table, Counting |
| 1942 | The Number of the Smallest Unoccupied Chair | Medium | Array, Hash Table, Heap (Priority Queue) |
| 1943 | Describe the Painting | Medium | Array, Hash Table, Prefix Sum +1 |
| 1980 | Find Unique Binary String | Medium | Array, Hash Table, String +1 |
| 1983 | Widest Pair of Indices With Equal Range SumPremium | Medium | Array, Hash Table, Prefix Sum |
| 1993 | Operations on Tree | Medium | Tree, Depth-First Search, Breadth-First Search +3 |
| 2001 | Number of Pairs of Interchangeable Rectangles | Medium | Array, Hash Table, Math +2 |
| 2007 | Find Original Array From Doubled Array | Medium | Greedy, Array, Hash Table +1 |
| 2008 | Maximum Earnings From Taxi | Medium | Array, Hash Table, Binary Search +2 |
| 2023 | Number of Pairs of Strings With Concatenation Equal to Target | Medium | Array, Hash Table, String +1 |
| 2029 | Stone Game IX | Medium | Greedy, Array, Math +2 |
| 2031 | Count Subarrays With More Ones Than ZerosPremium | Medium | Binary Indexed Tree, Segment Tree, Array +5 |
| 2034 | Stock Price Fluctuation | Medium | Design, Hash Table, Data Stream +2 |
| 2043 | Simple Bank System | Medium | Design, Array, Hash Table +1 |
| 2048 | Next Greater Numerically Balanced Number | Medium | Hash Table, Math, Backtracking +2 |
| 2067 | Number of Equal Count SubstringsPremium | Medium | Hash Table, String, Counting +1 |
| 2075 | Decode the Slanted Ciphertext | Medium | String, Simulation |
| 2080 | Range Frequency Queries | Medium | Design, Segment Tree, Array +2 |
| 2083 | Substrings That Begin and End With the Same LetterPremium | Medium | Hash Table, Math, String +2 |
| 2107 | Number of Unique Flavors After Sharing K CandiesPremium | Medium | Array, Hash Table, Sliding Window |
| 2115 | Find All Possible Recipes from Given Supplies | Medium | Graph, Topological Sort, Array +2 |
| 2120 | Execution of All Suffix Instructions Staying in a Grid | Medium | String, Simulation |
| 2121 | Intervals Between Identical Elements | Medium | Array, Hash Table, Prefix Sum |
| 2131 | Longest Palindrome by Concatenating Two Letter Words | Medium | Greedy, Array, Hash Table +2 |
| 2135 | Count Words Obtained After Adding a Letter | Medium | Bit Manipulation, Array, Hash Table +2 |
| 2150 | Find All Lonely Numbers in the Array | Medium | Array, Hash Table, Counting |
| 2152 | Minimum Number of Lines to Cover PointsPremium | Medium | Bit Manipulation, Geometry, Array +5 |
| 2166 | Design Bitset | Medium | Design, Array, Hash Table +1 |
| 2168 | Unique Substrings With Equal Digit FrequencyPremium | Medium | Hash Table, String, Counting +2 |
| 2170 | Minimum Operations to Make the Array Alternating | Medium | Greedy, Array, Hash Table +1 |
| 2182 | Construct String With Repeat Limit | Medium | Greedy, Hash Table, String +2 |
| 2186 | Minimum Number of Steps to Make Two Strings Anagram II | Medium | Hash Table, String, Counting |
| 2196 | Create Binary Tree From Descriptions | Medium | Tree, Array, Hash Table +1 |
| 2201 | Count Artifacts That Can Be Extracted | Medium | Array, Hash Table, Simulation |
| 2225 | Find Players With Zero or One Losses | Medium | Array, Hash Table, Counting +1 |
| 2232 | Minimize Result by Adding Parentheses to Expression | Medium | String, Enumeration |
| 2244 | Minimum Rounds to Complete All Tasks | Medium | Greedy, Array, Hash Table +1 |
| 2249 | Count Lattice Points Inside a Circle | Medium | Geometry, Array, Hash Table +2 |
| 2250 | Count Number of Rectangles Containing Each Point | Medium | Binary Indexed Tree, Array, Hash Table +2 |
| 2260 | Minimum Consecutive Cards to Pick Up | Medium | Array, Hash Table, Sliding Window |
| 2261 | K Divisible Elements Subarrays | Medium | Trie, Array, Hash Table +3 |
| 2266 | Count Number of Texts | Medium | Hash Table, Math, String +1 |
| 2268 | Minimum Number of KeypressesPremium | Medium | Greedy, Hash Table, String +2 |
| 2275 | Largest Combination With Bitwise AND Greater Than Zero | Medium | Bit Manipulation, Array, Hash Table +1 |
| 2284 | Sender With Largest Word Count | Medium | Array, Hash Table, String +1 |
| 2288 | Apply Discount to Prices | Medium | String |
| 2295 | Replace Elements in an Array | Medium | Array, Hash Table, Simulation |
| 2342 | Max Sum of a Pair With Equal Sum of Digits | Medium | Array, Hash Table, Sorting +1 |
| 2349 | Design a Number Container System | Medium | Design, Hash Table, Ordered Set +1 |
| 2353 | Design a Food Rating System | Medium | Design, Array, Hash Table +3 |
| 2364 | Count Number of Bad Pairs | Medium | Array, Hash Table, Math +1 |
| 2365 | Task Scheduler II | Medium | Array, Hash Table, Simulation |
| 2368 | Reachable Nodes With Restrictions | Medium | Tree, Depth-First Search, Breadth-First Search +4 |
| 2370 | Longest Ideal Subsequence | Medium | Hash Table, String, Dynamic Programming |
| 2374 | Node With Highest Edge Score | Medium | Graph, Hash Table |
| 2384 | Largest Palindromic Number | Medium | Greedy, Hash Table, String +1 |
| 2385 | Amount of Time for Binary Tree to Be Infected | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 2405 | Optimal Partition of String | Medium | Greedy, Hash Table, String |
| 2408 | Design SQLPremium | Medium | Design, Array, Hash Table +1 |
| 2414 | Length of the Longest Alphabetical Continuous Substring | Medium | String |
| 2424 | Longest Uploaded Prefix | Medium | Union Find, Design, Binary Indexed Tree +5 |
| 2434 | Using a Robot to Print the Lexicographically Smallest String | Medium | Stack, Greedy, Hash Table +1 |
| 2442 | Count Number of Distinct Integers After Reverse Operations | Medium | Array, Hash Table, Math +1 |
| 2453 | Destroy Sequential Targets | Medium | Array, Hash Table, Counting |
| 2456 | Most Popular Video Creator | Medium | Array, Hash Table, String +2 |
| 2461 | Maximum Sum of Distinct Subarrays With Length K | Medium | Array, Hash Table, Sliding Window |
| 2489 | Number of Substrings With Fixed RatioPremium | Medium | Hash Table, Math, String +1 |
| 2491 | Divide Players Into Teams of Equal Skill | Medium | Array, Hash Table, Two Pointers +1 |
| 2501 | Longest Square Streak in an Array | Medium | Array, Hash Table, Binary Search +2 |
| 2502 | Design Memory Allocator | Medium | Design, Array, Hash Table +1 |
| 2512 | Reward Top K Students | Medium | Array, Hash Table, String +2 |
| 2516 | Take K of Each Character From Left and Right | Medium | Hash Table, String, Sliding Window |
| 2521 | Distinct Prime Factors of Product of Array | Medium | Array, Hash Table, Math +1 |
| 2526 | Find Consecutive Integers from a Data Stream | Medium | Design, Queue, Hash Table +2 |
| 2531 | Make Number of Distinct Characters Equal | Medium | Hash Table, String, Counting |
| 2537 | Count the Number of Good Subarrays | Medium | Array, Hash Table, Sliding Window |
| 2539 | Count the Number of Good SubsequencesPremium | Medium | Hash Table, Math, String +2 |
| 2554 | Maximum Number of Integers to Choose From a Range I | Medium | Greedy, Array, Hash Table +2 |
| 2564 | Substring XOR Queries | Medium | Bit Manipulation, Array, Hash Table +1 |
| 2588 | Count the Number of Beautiful Subarrays | Medium | Bit Manipulation, Array, Hash Table +1 |
| 2590 | Design a Todo ListPremium | Medium | Design, Array, Hash Table +2 |
| 2593 | Find Score of an Array After Marking All Elements | Medium | Array, Hash Table, Sorting +2 |
| 2597 | The Number of Beautiful Subsets | Medium | Array, Hash Table, Math +4 |
| 2598 | Smallest Missing Non-negative Integer After Operations | Medium | Greedy, Array, Hash Table +1 |
| 2606 | Find the Substring With Maximum Cost | Medium | Array, Hash Table, String +1 |
| 2610 | Convert an Array Into a 2D Array With Conditions | Medium | Array, Hash Table |
| 2615 | Sum of Distances | Medium | Array, Hash Table, Prefix Sum |
| 2641 | Cousins in Binary Tree II | Medium | Tree, Depth-First Search, Breadth-First Search +2 |
| 2653 | Sliding Subarray Beauty | Medium | Array, Hash Table, Sliding Window |
| 2657 | Find the Prefix Common Array of Two Arrays | Medium | Bit Manipulation, Array, Hash Table |
| 2661 | First Completely Painted Row or Column | Medium | Array, Hash Table, Matrix |
| 2671 | Frequency Tracker | Medium | Design, Hash Table |
| 2707 | Extra Characters in a String | Medium | Trie, Array, Hash Table +2 |
| 2711 | Difference of Number of Distinct Values on Diagonals | Medium | Array, Hash Table, Matrix |
| 2718 | Sum of Matrix After Queries | Medium | Array, Hash Table |
| 2743 | Count Substrings Without Repeating CharacterPremium | Medium | Hash Table, String, Sliding Window |
| 2747 | Count Zero Request Servers | Medium | Array, Hash Table, Sorting +1 |
| 2766 | Relocate Marbles | Medium | Array, Hash Table, Sorting +1 |
| 2767 | Partition String Into Minimum Beautiful Substrings | Medium | Hash Table, String, Dynamic Programming +1 |
| 2768 | Number of Black Blocks | Medium | Array, Hash Table, Enumeration |
| 2780 | Minimum Index of a Valid Split | Medium | Array, Hash Table, Sorting |
| 2782 | Number of Unique CategoriesPremium | Medium | Union Find, Counting, Interactive |
| 2799 | Count Complete Subarrays in an Array | Medium | Array, Hash Table, Sliding Window |
| 2808 | Minimum Seconds to Equalize a Circular Array | Medium | Array, Hash Table |
| 2830 | Maximize the Profit as the Salesman | Medium | Array, Hash Table, Binary Search +2 |
| 2831 | Find the Longest Equal Subarray | Medium | Array, Hash Table, Binary Search +1 |
| 2840 | Check if Strings Can be Made Equal With Operations II | Medium | Hash Table, String, Sorting |
| 2841 | Maximum Sum of Almost Unique Subarray | Medium | Array, Hash Table, Sliding Window |
| 2845 | Count of Interesting Subarrays | Medium | Array, Hash Table, Prefix Sum |
| 2852 | Sum of Remoteness of All CellsPremium | Medium | Depth-First Search, Breadth-First Search, Union Find +3 |
| 2856 | Minimum Array Length After Pair Removals | Medium | Greedy, Array, Hash Table +3 |
| 2857 | Count Pairs of Points With Distance k | Medium | Bit Manipulation, Array, Hash Table |
| 2870 | Minimum Number of Operations to Make Array Empty | Medium | Greedy, Array, Hash Table +1 |
| 2875 | Minimum Size Subarray in Infinite Array | Medium | Array, Hash Table, Prefix Sum +1 |
| 2898 | Maximum Linear Stock ScorePremium | Medium | Array, Hash Table |
| 2910 | Minimum Number of Groups to Create a Valid Assignment | Medium | Greedy, Array, Hash Table |
| 2914 | Minimum Number of Changes to Make Binary String Beautiful | Medium | String |
| 2933 | High-Access Employees | Medium | Array, Hash Table, String +1 |
| 2947 | Count Beautiful Substrings I | Medium | Hash Table, Math, String +3 |
| 2950 | Number of Divisible SubstringsPremium | Medium | Hash Table, String, Counting +1 |
| 2955 | Number of Same-End SubstringsPremium | Medium | Array, Hash Table, String +2 |
| 2958 | Length of Longest Subarray With at Most K Frequency | Medium | Array, Hash Table, Sliding Window |
| 2964 | Number of Divisible Triplet SumsPremium | Medium | Array, Hash Table |
| 2975 | Maximum Square Area by Removing Fences From a Field | Medium | Array, Hash Table, Enumeration |
| 2981 | Find Longest Special Substring That Occurs Thrice I | Medium | Hash Table, String, Binary Search +2 |
| 2982 | Find Longest Special Substring That Occurs Thrice II | Medium | Hash Table, String, Binary Search +2 |
Hard (110)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 30 | Substring with Concatenation of All Words | Hard | Hash Table, String, Sliding Window |
| 37 | Sudoku Solver | Hard | Array, Hash Table, Backtracking +1 |
| 41 | First Missing Positive | Hard | Array, Hash Table |
| 65 | Valid Number | Hard | String |
| 68 | Text Justification | Hard | Array, String, Simulation |
| 76 | Minimum Window Substring | Hard | Hash Table, String, Sliding Window |
| 126 | Word Ladder II | Hard | Breadth-First Search, Hash Table, String +1 |
| 127 | Word Ladder | Hard | Breadth-First Search, Hash Table, String |
| 140 | Word Break II | Hard | Trie, Memoization, Array +4 |
| 149 | Max Points on a Line | Hard | Geometry, Array, Hash Table +1 |
| 214 | Shortest Palindrome | Hard | String, String Matching, Hash Function +1 |
| 336 | Palindrome Pairs | Hard | Trie, Array, Hash Table +1 |
| 352 | Data Stream as Disjoint Intervals | Hard | Union Find, Design, Hash Table +3 |
| 381 | Insert Delete GetRandom O(1) - Duplicates allowed | Hard | Design, Array, Hash Table +2 |
| 391 | Perfect Rectangle | Hard | Geometry, Array, Hash Table +2 |
| 432 | All O`one Data Structure | Hard | Design, Hash Table, Linked List +1 |
| 460 | LFU Cache | Hard | Design, Hash Table, Linked List +1 |
| 480 | Sliding Window Median | Hard | Array, Hash Table, Sliding Window +1 |
| 632 | Smallest Range Covering Elements from K Lists | Hard | Greedy, Array, Hash Table +3 |
| 691 | Stickers to Spell Word | Hard | Bit Manipulation, Memoization, Array +5 |
| 710 | Random Pick with Blacklist | Hard | Array, Hash Table, Math +3 |
| 736 | Parse Lisp Expression | Hard | Stack, Recursion, Hash Table +1 |
| 745 | Prefix and Suffix Search | Hard | Design, Trie, Array +2 |
| 248 | Strobogrammatic Number IIIPremium | Hard | Recursion, Array, String |
| 305 | Number of Islands IIPremium | Hard | Union Find, Array, Hash Table |
| 358 | Rearrange String k Distance ApartPremium | Hard | Greedy, Hash Table, String +3 |
| 548 | Split Array with Equal SumPremium | Hard | Array, Hash Table, Prefix Sum |
| 588 | Design In-Memory File SystemPremium | Hard | Design, Trie, Hash Table +2 |
| 631 | Design Excel Sum FormulaPremium | Hard | Graph, Design, Topological Sort +4 |
| 711 | Number of Distinct Islands IIPremium | Hard | Depth-First Search, Breadth-First Search, Union Find +2 |
| 726 | Number of Atoms | Hard | Stack, Hash Table, String +1 |
| 761 | Special Binary String | Hard | Recursion, String |
| 770 | Basic Calculator IV | Hard | Stack, Recursion, Hash Table +2 |
| 815 | Bus Routes | Hard | Breadth-First Search, Array, Hash Table |
| 828 | Count Unique Characters of All Substrings of a Given String | Hard | Hash Table, String, Dynamic Programming |
| 839 | Similar String Groups | Hard | Depth-First Search, Breadth-First Search, Union Find +3 |
| 854 | K-Similar Strings | Hard | Breadth-First Search, Hash Table, String |
| 895 | Maximum Frequency Stack | Hard | Stack, Design, Hash Table +1 |
| 924 | Minimize Malware Spread | Hard | Depth-First Search, Breadth-First Search, Union Find +3 |
| 928 | Minimize Malware Spread II | Hard | Depth-First Search, Breadth-First Search, Union Find +3 |
| 952 | Largest Component Size by Common Factor | Hard | Union Find, Array, Hash Table +2 |
| 982 | Triples with Bitwise AND Equal To Zero | Hard | Bit Manipulation, Array, Hash Table |
| 987 | Vertical Order Traversal of a Binary Tree | Hard | Tree, Depth-First Search, Breadth-First Search +3 |
| 992 | Subarrays with K Different Integers | Hard | Array, Hash Table, Counting +1 |
| 996 | Number of Squareful Arrays | Hard | Bit Manipulation, Array, Hash Table +4 |
| 1001 | Grid Illumination | Hard | Array, Hash Table |
| 1036 | Escape a Large Maze | Hard | Depth-First Search, Breadth-First Search, Array +1 |
| 1074 | Number of Submatrices That Sum to Target | Hard | Array, Hash Table, Matrix +1 |
| 1096 | Brace Expansion II | Hard | Stack, Breadth-First Search, Hash Table +3 |
| 1121 | Divide Array Into Increasing SequencesPremium | Hard | Array, Counting |
| 1153 | String Transforms Into Another StringPremium | Hard | Graph, Hash Table, String |
| 1172 | Dinner Plate Stacks | Hard | Stack, Design, Hash Table +1 |
| 1178 | Number of Valid Words for Each Puzzle | Hard | Bit Manipulation, Trie, Array +2 |
| 1224 | Maximum Equal Frequency | Hard | Array, Hash Table |
| 1255 | Maximum Score Words Formed by Letters | Hard | Bit Manipulation, Array, Hash Table +5 |
| 1284 | Minimum Number of Flips to Convert Binary Matrix to Zero Matrix | Hard | Bit Manipulation, Breadth-First Search, Array +2 |
| 1345 | Jump Game IV | Hard | Breadth-First Search, Array, Hash Table |
| 1392 | Longest Happy Prefix | Hard | String, String Matching, Hash Function +1 |
| 1542 | Find Longest Awesome Substring | Hard | Bit Manipulation, Hash Table, String |
| 1713 | Minimum Operations to Make a Subsequence | Hard | Greedy, Array, Hash Table +1 |
| 1782 | Count Pairs Of Nodes | Hard | Graph, Array, Hash Table +4 |
| 1788 | Maximize the Beauty of the GardenPremium | Hard | Greedy, Array, Hash Table +1 |
| 1819 | Number of Different Subsequences GCDs | Hard | Array, Math, Counting +1 |
| 1857 | Largest Color Value in a Directed Graph | Hard | Graph, Topological Sort, Memoization +3 |
| 1912 | Design Movie Rental System | Hard | Design, Array, Hash Table +2 |
| 1932 | Merge BSTs to Create Single BST | Hard | Tree, Depth-First Search, Hash Table +2 |
| 1938 | Maximum Genetic Difference Query | Hard | Bit Manipulation, Depth-First Search, Trie +2 |
| 1948 | Delete Duplicate Folders in System | Hard | Trie, Array, Hash Table +2 |
| 1960 | Maximum Product of the Length of Two Palindromic Substrings | Hard | String, Hash Function, Rolling Hash |
| 1994 | The Number of Good Subsets | Hard | Bit Manipulation, Array, Hash Table +5 |
| 2009 | Minimum Number of Operations to Make Array Continuous | Hard | Array, Hash Table, Binary Search +1 |
| 2014 | Longest Subsequence Repeated k Times | Hard | Greedy, String, Backtracking +2 |
| 2019 | The Score of Students Solving Math Expression | Hard | Stack, Memoization, Array +4 |
| 2025 | Maximum Number of Ways to Partition an Array | Hard | Array, Hash Table, Counting +2 |
| 2122 | Recover the Original Array | Hard | Array, Hash Table, Two Pointers +2 |
| 2213 | Longest Substring of One Repeating Character | Hard | Segment Tree, Array, String +1 |
| 2227 | Encrypt and Decrypt Strings | Hard | Design, Trie, Array +2 |
| 2251 | Number of Flowers in Full Bloom | Hard | Array, Hash Table, Binary Search +3 |
| 2254 | Design Video Sharing PlatformPremium | Hard | Stack, Design, Hash Table +1 |
| 2262 | Total Appeal of A String | Hard | Hash Table, String, Dynamic Programming |
| 2301 | Match Substring After Replacement | Hard | Array, Hash Table, String +1 |
| 2306 | Naming a Company | Hard | Bit Manipulation, Array, Hash Table +2 |
| 2350 | Shortest Impossible Sequence of Rolls | Hard | Greedy, Array, Hash Table |
| 2354 | Number of Excellent Pairs | Hard | Bit Manipulation, Array, Hash Table +1 |
| 2402 | Meeting Rooms III | Hard | Array, Hash Table, Sorting +2 |
| 2416 | Sum of Prefix Scores of Strings | Hard | Trie, Array, String +1 |
| 2421 | Number of Good Paths | Hard | Tree, Union Find, Graph +3 |
| 2488 | Count Subarrays With Median K | Hard | Array, Hash Table, Prefix Sum |
| 2499 | Minimum Total Cost to Make Arrays Unequal | Hard | Greedy, Array, Hash Table +1 |
| 2508 | Add Edges to Make Degrees of All Nodes Even | Hard | Graph, Hash Table |
| 2514 | Count Anagrams | Hard | Hash Table, Math, String +2 |
| 2524 | Maximum Frequency Score of a SubarrayPremium | Hard | Stack, Array, Hash Table +2 |
| 2547 | Minimum Cost to Split an Array | Hard | Array, Hash Table, Dynamic Programming +1 |
| 2561 | Rearranging Fruits | Hard | Greedy, Sort, Array +1 |
| 2581 | Count Number of Possible Root Nodes | Hard | Tree, Depth-First Search, Array +2 |
| 2584 | Split the Array to Make Coprime Products | Hard | Array, Hash Table, Math +1 |
| 2612 | Minimum Reverse Operations | Hard | Breadth-First Search, Union Find, Array +2 |
| 2713 | Maximum Strictly Increasing Cells in a Matrix | Hard | Memoization, Array, Hash Table +5 |
| 2732 | Find a Good Subset of the Matrix | Hard | Bit Manipulation, Array, Hash Table +1 |
| 2763 | Sum of Imbalance Numbers of All Subarrays | Hard | Array, Hash Table, Enumeration |
| 2781 | Length of the Longest Valid Substring | Hard | Array, Hash Table, String +1 |
| 2813 | Maximum Elegance of a K-Length Subsequence | Hard | Stack, Greedy, Array +3 |
| 2842 | Count K-Subsequences of a String With Maximum Beauty | Hard | Greedy, Hash Table, Math +2 |
| 2897 | Apply Operations on Array to Maximize Sum of Squares | Hard | Greedy, Bit Manipulation, Array +1 |
| 2902 | Count of Sub-Multisets With Bounded Sum | Hard | Array, Hash Table, Dynamic Programming +1 |
| 2935 | Maximum Strong Pair XOR II | Hard | Bit Manipulation, Trie, Array +2 |
| 2949 | Count Beautiful Substrings II | Hard | Hash Table, Math, String +2 |
| 2953 | Count Complete Substrings | Hard | Hash Table, String, Sliding Window |
| 2963 | Count the Number of Good Partitions | Hard | Array, Hash Table, Math +1 |
| 2983 | Palindrome Rearrangement Queries | Hard | Hash Table, String, Prefix Sum |
Related patterns
Problems sit in more than one pattern more often than not, and the overlap is where the interesting follow-up questions live.
Hash Map pattern FAQ
What is the hash map pattern?
A hash map converts a search into a lookup, which is why it is the most common single answer in this entire corpus — 588 of the 3000 problems are built on one.
How many LeetCode problems use the hash map pattern?
This page lists 709 LeetCode problems that the hash map pattern applies to: 227 Easy, 372 Medium and 110 Hard. 601 of them carry a complete Python solution with complexity analysis.
What is the time complexity of the hash map pattern?
O(1) average per operation, O(n) worst case time and O(n) space. Average-case constant lookups are what turn a nested-loop search into a single pass, so the complement and frequency-counting solutions are O(n) time and O(n) space. The worst case is linear per operation when every key collides, which is irrelevant on real data and is the reason a language's string hash is randomised per process. Ordering is not free: getting a sorted result out of a map costs the sort on top.
When should I use the hash map pattern in an interview?
The brute force is a nested loop asking "is there another element such that…". You are counting occurrences, or comparing two multisets.
Which hash map problem should I start with?
LeetCode 1. Two Sum is the lowest-numbered Easy problem on this page, which makes it the usual starting point: the technique is visible without the problem's own complications getting in the way.
What patterns are related to hash map?
Prefix Sum, Sliding Window, Sorting, Trie. Problems frequently sit in more than one of these, and the overlap is where the interesting follow-up questions come from.
More ways in: all 22 patterns, the curated study lists, or the full problem list.
Meet the hash map problem you did not practise
Stealth Interview is a desktop app for macOS and Windows. It reads the coding 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 is saying — while staying invisible to screen sharing.