Hash Function LeetCode Problems: All 25, With Python Solutions
Every problem in this library that LeetCode tags Hash Function — 25 in total, 18 of them with a complete Python solution, a worked example and the time and space complexity of the approach.
- 25 problems
- 3 Easy
- 10 Medium
- 12 Hard
Hash Function problems by difficulty
Problems with a complete Python solution are listed first, then by ascending problem number.
Easy (3)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 572 | Subtree of Another Tree | Easy | Tree, Depth-First Search, Binary Tree +2 |
| 705 | Design HashSet | Easy | Design, Array, Hash Table +2 |
| 706 | Design HashMap | Easy | Design, Array, Hash Table +2 |
Medium (10)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 187 | Repeated DNA Sequences | Medium | Bit Manipulation, Hash Table, String +3 |
| 535 | Encode and Decode TinyURL | Medium | Design, Hash Table, String +1 |
| 718 | Maximum Length of Repeated Subarray | Medium | Array, Binary Search, Dynamic Programming +3 |
| 1461 | Check If a String Contains All Binary Codes of Size K | Medium | Bit Manipulation, Hash Table, String +2 |
| 2261 | K Divisible Elements Subarrays | Medium | Trie, Array, Hash Table +3 |
| 694 | Number of Distinct IslandsPremium | Medium | Depth-First Search, Breadth-First Search, Union Find +2 |
| 1062 | Longest Repeating SubstringPremium | Medium | String, Binary Search, Dynamic Programming +3 |
| 1554 | Strings Differ by One CharacterPremium | Medium | Hash Table, String, Hash Function +1 |
| 1698 | Number of Distinct Substrings in a StringPremium | Medium | Trie, String, Suffix Array +2 |
| 2168 | Unique Substrings With Equal Digit FrequencyPremium | Medium | Hash Table, String, Counting +2 |
Hard (12)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 214 | Shortest Palindrome | Hard | String, String Matching, Hash Function +1 |
| 1044 | Longest Duplicate Substring | Hard | String, Binary Search, Suffix Array +3 |
| 1147 | Longest Chunked Palindrome Decomposition | Hard | Greedy, Two Pointers, String +3 |
| 1316 | Distinct Echo Substrings | Hard | Trie, String, Hash Function +1 |
| 1392 | Longest Happy Prefix | Hard | String, String Matching, Hash Function +1 |
| 1923 | Longest Common Subpath | Hard | Array, Binary Search, Suffix Array +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 |
| 2156 | Find Substring With Given Hash Value | Hard | String, Sliding Window, Hash Function +1 |
| 2430 | Maximum Deletions on a String | Hard | String, Dynamic Programming, String Matching +2 |
| 711 | Number of Distinct Islands IIPremium | Hard | Depth-First Search, Breadth-First Search, Union Find +2 |
| 2223 | Sum of Scores of Built Strings | Hard | String, Binary Search, String Matching +3 |
Keep exploring
All LeetCode topicsEvery tag with a page of its own, with the number of problems behind each.LeetCode patternsThe techniques themselves, with a Python template and complexity for each.Curated study listsBlind 75, NeetCode 150 and three more, grouped by pattern.Easy problemsStart here when the data structure is new rather than the problem.
Other topics
- Array1,569
- String672
- Hash Table588
- Math485
- Dynamic Programming481
- Sorting392
- Greedy346
- Depth-First Search289
- Binary Search253
- Database249
- Tree225
- Breadth-First Search223
- Matrix216
- Two Pointers201
- Bit Manipulation194
- Binary Tree174
- Heap (Priority Queue)163
- Prefix Sum157
- Stack157
- Simulation144
- Graph138
- Counting126
- Design122
- Sliding Window116
When the Hash Function problem arrives live
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.