Design LeetCode Problems: All 122, With Python Solutions
Every problem in this library that LeetCode tags Design — 122 in total, 89 of them with a complete Python solution, a worked example and the time and space complexity of the approach.
- 122 problems
- 13 Easy
- 79 Medium
- 30 Hard
Design problems by difficulty
Problems with a complete Python solution are listed first, then by ascending problem number.
Easy (13)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 225 | Implement Stack using Queues | Easy | Stack, Design, Queue |
| 232 | Implement Queue using Stacks | Easy | Stack, Design, Queue |
| 303 | Range Sum Query - Immutable | Easy | Design, Array, Prefix Sum |
| 703 | Kth Largest Element in a Stream | Easy | Tree, Design, Binary Search Tree +3 |
| 705 | Design HashSet | Easy | Design, Array, Hash Table +2 |
| 706 | Design HashMap | Easy | Design, Array, Hash Table +2 |
| 933 | Number of Recent Calls | Easy | Design, Queue, Data Stream |
| 1603 | Design Parking System | Easy | Design, Counting, Simulation |
| 1656 | Design an Ordered Stream | Easy | Design, Array, Hash Table +1 |
| 170 | Two Sum III - Data structure designPremium | Easy | Design, Array, Hash Table +2 |
| 346 | Moving Average from Data StreamPremium | Easy | Design, Queue, Array +1 |
| 359 | Logger Rate LimiterPremium | Easy | Design, Hash Table, Data Stream |
| 604 | Design Compressed String IteratorPremium | Easy | Design, Array, String +1 |
Medium (79)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 146 | LRU Cache | Medium | Design, Hash Table, Linked List +1 |
| 155 | Min Stack | Medium | Stack, Design |
| 173 | Binary Search Tree Iterator | Medium | Stack, Tree, Design +3 |
| 208 | Implement Trie (Prefix Tree) | Medium | Design, Trie, Hash Table +1 |
| 211 | Design Add and Search Words Data Structure | Medium | Depth-First Search, Design, Trie +1 |
| 284 | Peeking Iterator | Medium | Design, Array, Iterator |
| 304 | Range Sum Query 2D - Immutable | Medium | Design, Array, Matrix +1 |
| 307 | Range Sum Query - Mutable | Medium | Design, Binary Indexed Tree, Segment Tree +2 |
| 341 | Flatten Nested List Iterator | Medium | Stack, Tree, Depth-First Search +3 |
| 355 | Design Twitter | Medium | Design, Hash Table, Linked List +1 |
| 380 | Insert Delete GetRandom O(1) | Medium | Design, Array, Hash Table +2 |
| 384 | Shuffle an Array | Medium | Design, Array, Math +1 |
| 449 | Serialize and Deserialize BST | Medium | Tree, Depth-First Search, Breadth-First Search +4 |
| 535 | Encode and Decode TinyURL | Medium | Design, Hash Table, String +1 |
| 622 | Design Circular Queue | Medium | Design, Queue, Array +1 |
| 641 | Design Circular Deque | Medium | Design, Queue, Array +1 |
| 676 | Implement Magic Dictionary | Medium | Depth-First Search, Design, Trie +2 |
| 677 | Map Sum Pairs | Medium | Design, Trie, Hash Table +1 |
| 707 | Design Linked List | Medium | Design, Linked List |
| 729 | My Calendar I | Medium | Design, Segment Tree, Array +2 |
| 731 | My Calendar II | Medium | Design, Segment Tree, Array +3 |
| 855 | Exam Room | Medium | Design, Ordered Set, Heap (Priority Queue) |
| 900 | RLE Iterator | Medium | Design, Array, Counting +1 |
| 901 | Online Stock Span | Medium | Stack, Design, Data Stream +1 |
| 911 | Online Election | Medium | Design, Array, Hash Table +1 |
| 919 | Complete Binary Tree Inserter | Medium | Tree, Breadth-First Search, Design +1 |
| 981 | Time Based Key-Value Store | Medium | Design, Hash Table, String +1 |
| 1146 | Snapshot Array | Medium | Design, Array, Hash Table +1 |
| 1261 | Find Elements in a Contaminated Binary Tree | Medium | Tree, Depth-First Search, Breadth-First Search +3 |
| 1286 | Iterator for Combination | Medium | Design, String, Backtracking +1 |
| 1348 | Tweet Counts Per Frequency | Medium | Design, Hash Table, String +3 |
| 1352 | Product of the Last K Numbers | Medium | Design, Array, Math +2 |
| 1357 | Apply Discount Every n Orders | Medium | Design, Array, Hash Table |
| 1381 | Design a Stack With Increment Operation | Medium | Stack, Design, Array |
| 1396 | Design Underground System | Medium | Design, Hash Table, String |
| 1472 | Design Browser History | Medium | Stack, Design, Array +3 |
| 1476 | Subrectangle Queries | Medium | Design, Array, Matrix |
| 1600 | Throne Inheritance | Medium | Tree, Depth-First Search, Design +1 |
| 1670 | Design Front Middle Back Queue | Medium | Design, Queue, Array +2 |
| 1797 | Design Authentication Manager | Medium | Design, Hash Table, Linked List +1 |
| 1845 | Seat Reservation Manager | Medium | Design, Heap (Priority Queue) |
| 1865 | Finding Pairs With a Certain Sum | Medium | Design, Array, Hash Table |
| 1993 | Operations on Tree | Medium | Tree, Depth-First Search, Breadth-First Search +3 |
| 2013 | Detect Squares | Medium | Design, Array, Hash Table +1 |
| 2034 | Stock Price Fluctuation | Medium | Design, Hash Table, Data Stream +2 |
| 2043 | Simple Bank System | Medium | Design, Array, Hash Table +1 |
| 2080 | Range Frequency Queries | Medium | Design, Segment Tree, Array +2 |
| 2166 | Design Bitset | Medium | Design, Array, Hash Table +1 |
| 2241 | Design an ATM Machine | Medium | Greedy, Design, Array |
| 2336 | Smallest Number in Infinite Set | Medium | Design, Hash Table, Ordered Set +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 |
| 2424 | Longest Uploaded Prefix | Medium | Union Find, Design, Binary Indexed Tree +5 |
| 2502 | Design Memory Allocator | Medium | Design, Array, Hash Table +1 |
| 2526 | Find Consecutive Integers from a Data Stream | Medium | Design, Queue, Hash Table +2 |
| 2671 | Frequency Tracker | Medium | Design, Hash Table |
| 244 | Shortest Word Distance IIPremium | Medium | Design, Array, Hash Table +2 |
| 251 | Flatten 2D VectorPremium | Medium | Design, Array, Two Pointers +1 |
| 271 | Encode and Decode StringsPremium | Medium | Design, Array, String |
| 281 | Zigzag IteratorPremium | Medium | Design, Queue, Array +1 |
| 288 | Unique Word AbbreviationPremium | Medium | Design, Array, Hash Table +1 |
| 308 | Range Sum Query 2D - MutablePremium | Medium | Design, Binary Indexed Tree, Segment Tree +2 |
| 348 | Design Tic-Tac-ToePremium | Medium | Design, Array, Hash Table +2 |
| 353 | Design Snake GamePremium | Medium | Design, Queue, Array +2 |
| 362 | Design Hit CounterPremium | Medium | Design, Queue, Array +2 |
| 379 | Design Phone DirectoryPremium | Medium | Design, Queue, Array +2 |
| 635 | Design Log Storage SystemPremium | Medium | Design, Hash Table, String +1 |
| 1166 | Design File SystemPremium | Medium | Design, Trie, Hash Table +1 |
| 1244 | Design A LeaderboardPremium | Medium | Design, Hash Table, Sorting |
| 1429 | First Unique NumberPremium | Medium | Design, Queue, Array +2 |
| 1500 | Design a File Sharing SystemPremium | Medium | Design, Hash Table, Data Stream +2 |
| 1570 | Dot Product of Two Sparse VectorsPremium | Medium | Design, Array, Hash Table +1 |
| 1586 | Binary Search Tree Iterator IIPremium | Medium | Stack, Tree, Design +3 |
| 1628 | Design an Expression Tree With Evaluate FunctionPremium | Medium | Stack, Tree, Design +3 |
| 1756 | Design Most Recently Used QueuePremium | Medium | Design, Array, Linked List +3 |
| 1804 | Implement Trie II (Prefix Tree)Premium | Medium | Design, Trie, Hash Table +1 |
| 2069 | Walking Robot Simulation II | Medium | Design, Simulation |
| 2408 | Design SQLPremium | Medium | Design, Array, Hash Table +1 |
| 2590 | Design a Todo ListPremium | Medium | Design, Array, Hash Table +2 |
Hard (30)
| # | Problem | Difficulty | Topics |
|---|---|---|---|
| 295 | Find Median from Data Stream | Hard | Design, Two Pointers, Data Stream +2 |
| 297 | Serialize and Deserialize Binary Tree | Hard | Tree, Depth-First Search, Breadth-First Search +3 |
| 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 |
| 432 | All O`one Data Structure | Hard | Design, Hash Table, Linked List +1 |
| 460 | LFU Cache | Hard | Design, Hash Table, Linked List +1 |
| 715 | Range Module | Hard | Design, Segment Tree, Ordered Set |
| 732 | My Calendar III | Hard | Design, Segment Tree, Binary Search +2 |
| 745 | Prefix and Suffix Search | Hard | Design, Trie, Array +2 |
| 895 | Maximum Frequency Stack | Hard | Stack, Design, Hash Table +1 |
| 1032 | Stream of Characters | Hard | Design, Trie, Array +2 |
| 1157 | Online Majority Element In Subarray | Hard | Design, Binary Indexed Tree, Segment Tree +2 |
| 1172 | Dinner Plate Stacks | Hard | Stack, Design, Hash Table +1 |
| 1206 | Design Skiplist | Hard | Design, Linked List |
| 1483 | Kth Ancestor of a Tree Node | Hard | Bit Manipulation, Tree, Depth-First Search +4 |
| 1622 | Fancy Sequence | Hard | Design, Segment Tree, Math |
| 1825 | Finding MK Average | Hard | Design, Queue, Data Stream +2 |
| 1912 | Design Movie Rental System | Hard | Design, Array, Hash Table +2 |
| 2102 | Sequentially Ordinal Rank Tracker | Hard | Design, Data Stream, Ordered Set +1 |
| 2227 | Encrypt and Decrypt Strings | Hard | Design, Trie, Array +2 |
| 2276 | Count Integers in Intervals | Hard | Design, Segment Tree, Ordered Set |
| 2286 | Booking Concert Tickets in Groups | Hard | Design, Binary Indexed Tree, Segment Tree +1 |
| 2296 | Design a Text Editor | Hard | Stack, Design, Linked List +3 |
| 2642 | Design Graph With Shortest Path Calculator | Hard | Graph, Design, Shortest Path +1 |
| 431 | Encode N-ary Tree to Binary TreePremium | Hard | Tree, Depth-First Search, Breadth-First Search +2 |
| 588 | Design In-Memory File SystemPremium | Hard | Design, Trie, Hash Table +2 |
| 631 | Design Excel Sum FormulaPremium | Hard | Graph, Design, Topological Sort +4 |
| 642 | Design Search Autocomplete SystemPremium | Hard | Depth-First Search, Design, Trie +4 |
| 716 | Max StackPremium | Hard | Stack, Design, Linked List +2 |
| 2254 | Design Video Sharing PlatformPremium | Hard | Stack, Design, Hash Table +1 |
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
- Sliding Window116
- Backtracking105
When the Design 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.