Hash Map and Hashing coding problems
Hash maps turn slow nested loops into one pass. Practise frequency counting, seen-sets, grouping and the classic two-sum family, the patterns interviewers expect you to reach for first.
101 problems: 26 easy, 70 medium, 5 hard. Free to read; a free account solves them and earns XP and Aura.
- Count Character OccurrencesPractice · +10 XP · strings, loops, countingeasy
- Count Distinct ElementsPractice · +10 XP · sorting, counting, arrayseasy
- Count Element OccurrencesPractice · +10 XP · hash map, counting, frequencyeasy
- Count Elements Greater Than KPractice · +10 XP · hash map, counting, conditionalseasy
- Count Elements Greater Than NeighborPractice · +10 XP · arrays, countingeasy
- Count Elements Less Than K in WindowPractice · +10 XP · sliding window, countingeasy
- Count Non-Alphabetic CharactersPractice · +10 XP · strings, counting, loopseasy
- Count Number OccurrencesPractice · +10 XP · hash map, counting, frequencyeasy
- Count Numbers with Even Set BitsPractice · +10 XP · bit manipulation, loops, countingeasy
- Count Occurrences of a Target ValuePractice · +10 XP · arrays, loops, countingeasy
- Count Occurrences of Each NumberPractice · +10 XP · hash map, counting, frequencyeasy
- Count Pairs with Smaller SumPractice · +10 XP · two pointers, sorting, countingeasy
- Count Paths on a LinePractice · +10 XP · dynamic programming, recursion, countingeasy
- Count Specific CharactersPractice · +10 XP · strings, counting, loopseasy
- Count Specific ElementsPractice · +10 XP · hash map, counting, frequencyeasy
- Count Subarrays with Target SumPractice · +10 XP · sliding window, prefix sums, hash mapeasy
- Count Subsequences Summing to KPractice · +10 XP · dynamic programming, recursion, countingeasy
- Count Uppercase LettersPractice · +10 XP · strings, loops, countingeasy
- Count Value OccurrencesPractice · +10 XP · hash map, counting, frequencyeasy
- Count Vowel PairsPractice · +10 XP · strings, loops, countingeasy
- Majority ElementDaily · +5 XP · +3 Aura (late, half) · arrays, counting2 solvedeasy
- Most Frequent CharacterPractice · +10 XP · hash map, strings, countingeasy
- Most Frequent ElementPractice · +10 XP · hash map, counting, frequencyeasy
- Number of Students per CollegePractice · SQL · +10 XP · group by, sql, countingeasy
- String AnalyzerPractice · +10 XP · strings, counting, simple parsingeasy
- The Polite WaiterDaily · +5 XP · +3 Aura (late, half) · strings, counting, loops1 solvedeasy
- Array of SubarraysDaily · +15 XP · +5 Aura (late, half) · hash map, two pointers, subarray2 solvedmedium
- Consecutive DuplicatesPractice · +20 XP · arrays, counting, run-length encodingmedium
- Count Distinct Prefix SumsPractice · +20 XP · math, prefix sums, hashingmedium
- Count Distinct ValuesPractice · +20 XP · hash map, counting, frequencymedium
- Count Elements with Equal NeighborsPractice · +20 XP · hash map, counting, arraysmedium
- Count Matching PairsPractice · +20 XP · hash map, counting, arraysmedium
- Count Pairs with Digit Sum Divisible by KPractice · +20 XP · math, hashing, prefix sumsmedium
- Count Pairs with Equal Digit ProductPractice · +20 XP · math, hashing, number theorymedium
- Count Pairs with Equal Digit SumPractice · +20 XP · math, hashing, arraysmedium
- Count Pairs with Equal ProductPractice · +20 XP · arrays, hash map, countingmedium
- Count Pairs with Equal SumPractice · +20 XP · hash map, countingmedium
- Count Pairs with Equal XOR SumPractice · +20 XP · recursion, prefix sums, hash mapsmedium
- Count Pairs with Same RemainderPractice · +20 XP · hash map, counting, modulo arithmeticmedium
- Count Pairs with Sum Divisible by KPractice · +20 XP · arrays, hashing, number theorymedium
- Count Subarrays with Distinct ElementsPractice · +20 XP · hash map, sliding window, two pointersmedium
- Count Subarrays with Equal Prefix SumsPractice · +20 XP · prefix sums, hash map, countingmedium
- Count Subarrays with Target Sum DifferencePractice · +20 XP · prefix sums, hash map, subarray sumsmedium
- Count Uncommon ElementsPractice · +20 XP · hash map, countingmedium
- Count Unique Element PairsPractice · +20 XP · hash map, two pointers, sortingmedium
- Count XOR PairsPractice · +20 XP · bit manipulation, hash map, prefix sumsmedium
- Distinct Consecutive PairsPractice · +20 XP · arrays, hash map, countingmedium
- Distinct Element Sum with Minimum CostPractice · +20 XP · heaps, hash map, greedymedium
- Distinct Elements CountPractice · +20 XP · greedy, hash map, countingmedium
- Distinct Elements in a Sliding WindowPractice · +20 XP · arrays, hash map, sliding windowmedium
- Distinct Elements in PrefixPractice · +20 XP · arrays, hash set, prefix sumsmedium
- Distinct Elements in Sliding WindowPractice · +20 XP · stack, hash map, sliding windowmedium
- Distinct Elements with Minimum Total CostPractice · +20 XP · heaps, hash set, greedymedium
- Distinct Row CountsPractice · +20 XP · matrix, hashing, data structuresmedium
- Distinct Subgrid ValuesPractice · +20 XP · matrix, prefix sums, hash setmedium
- Distinct XOR Prefix SumsPractice · +20 XP · bit manipulation, prefix sums, hash setmedium
- Divisible by Last DigitPractice · +20 XP · math, number theory, hash mapmedium
- Find Duplicate Cycle EntryPractice · +20 XP · linked structures, hash map, cycle detectionmedium
- Find Duplicate Jump TargetPractice · +20 XP · linked structures, hash map, simulationmedium
- Find K Distinct Element FrequenciesPractice · +20 XP · heaps, frequency counting, top-kmedium
- Find the First Unique ElementPractice · +20 XP · hash map, arrays, frequencymedium
- Group by PropertyPractice · +20 XP · hash map, grouping, sortingmedium
- Group by ValuePractice · +20 XP · hash map, grouping, arraysmedium
- Linked List CompressionPractice · +20 XP · linked structures, hash maps, simulationmedium
- Linked List Path SumPractice · +20 XP · linked structures, hash map, cycle detectionmedium
- Longest Common SuffixPractice · +20 XP · strings, hashing, suffix arraymedium
- Longest Prefix with Equal CountsPractice · +20 XP · stack, hash map, prefix summedium
- Longest Prefix With No RepeatsPractice · +20 XP · strings, sliding window, hash setmedium
- Longest Segment with At Most K Distinct ElementsPractice · +20 XP · sliding window, hash map, frequency countingmedium
- Longest Subarray with At Most K Distinct ElementsPractice · +20 XP · two pointers, sliding window, hash mapmedium
- Longest Subarray with At Most K Duplicate PairsPractice · +20 XP · sliding window, hash map, arraysmedium
- Longest Subarray with Equal HalvesPractice · +20 XP · sliding window, prefix sums, hash mapmedium
- Longest Subarray With Sum XPractice · +20 XP · sliding window, prefix sums, hash mapmedium
- Longest Substring With At Most K Distinct CharactersPractice · +20 XP · strings, sliding window, hash mapmedium
- Longest Substring Without RepeatsPractice · +20 XP · sliding window, hash map, stringsmedium
- Matrix Neighbors SumPractice · +20 XP · matrix, bfs, hash mapmedium
- Matrix Zero Sum SubgridsPractice · +20 XP · matrix, prefix sums, hash mapmedium
- Minimum XOR Sum of SubarraysPractice · +20 XP · bit manipulation, prefix sums, hash mapmedium
- Most Frequent Row XORPractice · +20 XP · matrix, hash map, frequencymedium
- Most Frequent SubstringPractice · +20 XP · strings, hashing, countingmedium
- Pairs with Sum Divisible by KPractice · +20 XP · math, number theory, hash mapmedium
- Sort by Subsequence SumPractice · +20 XP · sorting, hash map, prefix summedium
- String PartitionPractice · +20 XP · strings, hashing, prefix sumsmedium
- String with Most Unique CharactersPractice · +20 XP · strings, sliding window, hash mapmedium
- Subarray Sum and CountPractice · +20 XP · prefix sums, hash map, range queriesmedium
- Subarray Sum FrequenciesPractice · +20 XP · prefix sums, hash map, subarray sumsmedium
- Subarray Sum MultiplesPractice · +20 XP · prefix sums, hash maps, number theorymedium
- Subarray Sums with Target DifferencePractice · +20 XP · prefix sums, hash maps, countingmedium
- Subarray with Target ProductPractice · +20 XP · arrays, hash map, prefix productmedium
- Subarray XOR with TargetPractice · +20 XP · bit manipulation, hash map, prefix summedium
- Subsegment Sum Divisible by KPractice · +20 XP · recursion, prefix sums, hashingmedium
- Sum of Distinct ElementsPractice · +20 XP · recursion, hashing, arraysmedium
- Tree Subtree SumsPractice · +20 XP · trees, dfs, hash mapmedium
- Two Sum Modulo KPractice · +20 XP · math, hashing, number theorymedium
- XOR Pairs with Zero SumPractice · +20 XP · bit manipulation, hash map, prefix sumsmedium
- XOR Sequence PartitionPractice · +20 XP · bit manipulation, hash map, prefix sumsmedium
- Distinct Subarrays with Bounded SumPractice · +30 XP · two pointers, hash map, combinatoricshard
- Distinct Subsequences CountPractice · +30 XP · hash map, dynamic programming, stringhard
- Longest Balanced SubarrayPractice · +30 XP · arrays, hash maps, prefix sumshard
- Longest Subarray with Distinct ElementsPractice · +30 XP · hash map, sliding window, two pointershard
- Longest Subarray with Equal Number of Zeroes and OnesPractice · +30 XP · two pointers, prefix sum, hash maphard
Solve these free. Get paid in XP and Aura.
One tap with Google, no card. Every first accepted solve pays XP for the leaderboards and Aura for real goodies.
Other topics
Arrays88Prefix Sums64SQL and Databases64Beginner Coding Problems60Graphs, BFS and DFS45Greedy41Sliding Window39Dynamic Programming37Sorting36Math and Number Theory36Strings35Two Pointers35Stack29Binary Search25Simulation25Recursion22Linked List20Trees20Heap and Priority Queue18Matrix and Grid18Bit Manipulation18Queue and Deque16