> ## Documentation Index
> Fetch the complete documentation index at: https://leetcode-py.wisl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> leetcode-py is a Python LeetCode practice environment generator with one CLI: lcpy. It is not a service or platform.
> Each problem is a directory under leetcode/ with README.md, solution.py, test_solution.py, helpers.py, and playground.ipynb. lcpy gen creates them from JSON templates bundled with the package.
> Examples are backed by tests; copy them verbatim.

# Design in Python with Tests

> All 76 Design LeetCode problems with tested Python solutions.

Design holds 76 problems (13 Easy, 48 Medium, 15 Hard).
Generate any of them into the current directory with `lcpy gen -n <number>`.

| # | Problem | Difficulty | Solution |
| - | - | - | - |
| 146 | [LRU Cache](https://leetcode-py.wisl.dev/problems/lru-cache) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lru_cache/solution.py) |
| 155 | [Min Stack](https://leetcode-py.wisl.dev/problems/min-stack) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/min_stack/solution.py) |
| 170 | [Two Sum III - Data structure design](https://leetcode-py.wisl.dev/problems/two-sum-iii-data-structure-design) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/two_sum_iii_data_structure_design/solution.py) |
| 173 | [Binary Search Tree Iterator](https://leetcode-py.wisl.dev/problems/binary-search-tree-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_search_tree_iterator/solution.py) |
| 208 | [Implement Trie (Prefix Tree)](https://leetcode-py.wisl.dev/problems/implement-trie-prefix-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_trie_prefix_tree/solution.py) |
| 211 | [Design Add and Search Words Data Structure](https://leetcode-py.wisl.dev/problems/design-add-and-search-words-data-structure) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_add_and_search_words_data_structure/solution.py) |
| 225 | [Implement Stack using Queues](https://leetcode-py.wisl.dev/problems/implement-stack-using-queues) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_stack_using_queues/solution.py) |
| 232 | [Implement Queue using Stacks](https://leetcode-py.wisl.dev/problems/implement-queue-using-stacks) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_queue_using_stacks/solution.py) |
| 244 | [Shortest Word Distance II](https://leetcode-py.wisl.dev/problems/shortest-word-distance-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_word_distance_ii/solution.py) |
| 251 | [Flatten 2D Vector](https://leetcode-py.wisl.dev/problems/flatten-2d-vector) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_2d_vector/solution.py) |
| 271 | [Encode and Decode Strings](https://leetcode-py.wisl.dev/problems/encode-and-decode-strings) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_and_decode_strings/solution.py) |
| 281 | [Zigzag Iterator](https://leetcode-py.wisl.dev/problems/zigzag-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/zigzag_iterator/solution.py) |
| 284 | [Peeking Iterator](https://leetcode-py.wisl.dev/problems/peeking-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/peeking_iterator/solution.py) |
| 288 | [Unique Word Abbreviation](https://leetcode-py.wisl.dev/problems/unique-word-abbreviation) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_word_abbreviation/solution.py) |
| 295 | [Find Median from Data Stream](https://leetcode-py.wisl.dev/problems/find-median-from-data-stream) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_median_from_data_stream/solution.py) |
| 297 | [Serialize and Deserialize Binary Tree](https://leetcode-py.wisl.dev/problems/serialize-and-deserialize-binary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_binary_tree/solution.py) |
| 303 | [Range Sum Query - Immutable](https://leetcode-py.wisl.dev/problems/range-sum-query-immutable) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_immutable/solution.py) |
| 304 | [Range Sum Query 2D - Immutable](https://leetcode-py.wisl.dev/problems/range-sum-query-2d-immutable) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_2d_immutable/solution.py) |
| 307 | [Range Sum Query - Mutable](https://leetcode-py.wisl.dev/problems/range-sum-query-mutable) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_mutable/solution.py) |
| 308 | [Range Sum Query 2D - Mutable](https://leetcode-py.wisl.dev/problems/range-sum-query-2d-mutable) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_query_2d_mutable/solution.py) |
| 341 | [Flatten Nested List Iterator](https://leetcode-py.wisl.dev/problems/flatten-nested-list-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_nested_list_iterator/solution.py) |
| 346 | [Moving Average from Data Stream](https://leetcode-py.wisl.dev/problems/moving-average-from-data-stream) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/moving_average_from_data_stream/solution.py) |
| 348 | [Design Tic-Tac-Toe](https://leetcode-py.wisl.dev/problems/design-tic-tac-toe) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_tic_tac_toe/solution.py) |
| 352 | [Data Stream as Disjoint Intervals](https://leetcode-py.wisl.dev/problems/data-stream-as-disjoint-intervals) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/data_stream_as_disjoint_intervals/solution.py) |
| 353 | [Design Snake Game](https://leetcode-py.wisl.dev/problems/design-snake-game) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_snake_game/solution.py) |
| 355 | [Design Twitter](https://leetcode-py.wisl.dev/problems/design-twitter) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_twitter/solution.py) |
| 359 | [Logger Rate Limiter](https://leetcode-py.wisl.dev/problems/logger-rate-limiter) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/logger_rate_limiter/solution.py) |
| 362 | [Design Hit Counter](https://leetcode-py.wisl.dev/problems/design-hit-counter) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_hit_counter/solution.py) |
| 379 | [Design Phone Directory](https://leetcode-py.wisl.dev/problems/design-phone-directory) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_phone_directory/solution.py) |
| 380 | [Insert Delete GetRandom O(1)](https://leetcode-py.wisl.dev/problems/insert-delete-getrandom-o1) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_delete_getrandom_o1/solution.py) |
| 381 | [Insert Delete GetRandom O(1) - Duplicates allowed](https://leetcode-py.wisl.dev/problems/insert-delete-getrandom-o1-duplicates-allowed) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_delete_getrandom_o1_duplicates_allowed/solution.py) |
| 384 | [Shuffle an Array](https://leetcode-py.wisl.dev/problems/shuffle-an-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shuffle_an_array/solution.py) |
| 431 | [Encode N-ary Tree to Binary Tree](https://leetcode-py.wisl.dev/problems/encode-n-ary-tree-to-binary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_n_ary_tree_to_binary_tree/solution.py) |
| 432 | [All O\`one Data Structure](https://leetcode-py.wisl.dev/problems/all-oone-data-structure) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/all_oone_data_structure/solution.py) |
| 449 | [Serialize and Deserialize BST](https://leetcode-py.wisl.dev/problems/serialize-and-deserialize-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_bst/solution.py) |
| 460 | [LFU Cache](https://leetcode-py.wisl.dev/problems/lfu-cache) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lfu_cache/solution.py) |
| 535 | [Encode and Decode TinyURL](https://leetcode-py.wisl.dev/problems/encode-and-decode-tinyurl) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/encode_and_decode_tinyurl/solution.py) |
| 588 | [Design In-Memory File System](https://leetcode-py.wisl.dev/problems/design-in-memory-file-system) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_in_memory_file_system/solution.py) |
| 604 | [Design Compressed String Iterator](https://leetcode-py.wisl.dev/problems/design-compressed-string-iterator) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_compressed_string_iterator/solution.py) |
| 622 | [Design Circular Queue](https://leetcode-py.wisl.dev/problems/design-circular-queue) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_circular_queue/solution.py) |
| 631 | [Design Excel Sum Formula](https://leetcode-py.wisl.dev/problems/design-excel-sum-formula) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_excel_sum_formula/solution.py) |
| 635 | [Design Log Storage System](https://leetcode-py.wisl.dev/problems/design-log-storage-system) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_log_storage_system/solution.py) |
| 641 | [Design Circular Deque](https://leetcode-py.wisl.dev/problems/design-circular-deque) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_circular_deque/solution.py) |
| 642 | [Design Search Autocomplete System](https://leetcode-py.wisl.dev/problems/design-search-autocomplete-system) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_search_autocomplete_system/solution.py) |
| 676 | [Implement Magic Dictionary](https://leetcode-py.wisl.dev/problems/implement-magic-dictionary) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_magic_dictionary/solution.py) |
| 677 | [Map Sum Pairs](https://leetcode-py.wisl.dev/problems/map-sum-pairs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/map_sum_pairs/solution.py) |
| 703 | [Kth Largest Element in a Stream](https://leetcode-py.wisl.dev/problems/kth-largest-element-in-a-stream) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_largest_element_in_a_stream/solution.py) |
| 705 | [Design HashSet](https://leetcode-py.wisl.dev/problems/design-hash-set) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_hash_set/solution.py) |
| 706 | [Design HashMap](https://leetcode-py.wisl.dev/problems/design-hash-map) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_hash_map/solution.py) |
| 707 | [Design Linked List](https://leetcode-py.wisl.dev/problems/design-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_linked_list/solution.py) |
| 715 | [Range Module](https://leetcode-py.wisl.dev/problems/range-module) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_module/solution.py) |
| 716 | [Max Stack](https://leetcode-py.wisl.dev/problems/max-stack) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_stack/solution.py) |
| 729 | [My Calendar I](https://leetcode-py.wisl.dev/problems/my-calendar-i) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/my_calendar_i/solution.py) |
| 731 | [My Calendar II](https://leetcode-py.wisl.dev/problems/my-calendar-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/my_calendar_ii/solution.py) |
| 732 | [My Calendar III](https://leetcode-py.wisl.dev/problems/my-calendar-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/my_calendar_iii/solution.py) |
| 745 | [Prefix and Suffix Search](https://leetcode-py.wisl.dev/problems/prefix-and-suffix-search) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/prefix_and_suffix_search/solution.py) |
| 855 | [Exam Room](https://leetcode-py.wisl.dev/problems/exam-room) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/exam_room/solution.py) |
| 895 | [Maximum Frequency Stack](https://leetcode-py.wisl.dev/problems/maximum-frequency-stack) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_frequency_stack/solution.py) |
| 900 | [RLE Iterator](https://leetcode-py.wisl.dev/problems/rle-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/rle_iterator/solution.py) |
| 901 | [Online Stock Span](https://leetcode-py.wisl.dev/problems/online-stock-span) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/online_stock_span/solution.py) |
| 911 | [Online Election](https://leetcode-py.wisl.dev/problems/online-election) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/online_election/solution.py) |
| 919 | [Complete Binary Tree Inserter](https://leetcode-py.wisl.dev/problems/complete-binary-tree-inserter) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/complete_binary_tree_inserter/solution.py) |
| 933 | [Number of Recent Calls](https://leetcode-py.wisl.dev/problems/number-of-recent-calls) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_recent_calls/solution.py) |
| 981 | [Time Based Key-Value Store](https://leetcode-py.wisl.dev/problems/time-based-key-value-store) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/time_based_key_value_store/solution.py) |
| 1166 | [Design File System](https://leetcode-py.wisl.dev/problems/design-file-system) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_file_system/solution.py) |
| 1244 | [Design A Leaderboard](https://leetcode-py.wisl.dev/problems/design-a-leaderboard) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_a_leaderboard/solution.py) |
| 1279 | [Traffic Light Controlled Intersection](https://leetcode-py.wisl.dev/problems/traffic-light-controlled-intersection) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/traffic_light_controlled_intersection/solution.py) |
| 1396 | [Design Underground System](https://leetcode-py.wisl.dev/problems/design-underground-system) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_underground_system/solution.py) |
| 1429 | [First Unique Number](https://leetcode-py.wisl.dev/problems/first-unique-number) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/first_unique_number/solution.py) |
| 1472 | [Design Browser History](https://leetcode-py.wisl.dev/problems/design-browser-history) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_browser_history/solution.py) |
| 1570 | [Dot Product of Two Sparse Vectors](https://leetcode-py.wisl.dev/problems/dot-product-of-two-sparse-vectors) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/dot_product_of_two_sparse_vectors/solution.py) |
| 1603 | [Design Parking System](https://leetcode-py.wisl.dev/problems/design-parking-system) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_parking_system/solution.py) |
| 1845 | [Seat Reservation Manager](https://leetcode-py.wisl.dev/problems/seat-reservation-manager) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/seat_reservation_manager/solution.py) |
| 1993 | [Operations on Tree](https://leetcode-py.wisl.dev/problems/operations-on-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/operations_on_tree/solution.py) |
| 2013 | [Detect Squares](https://leetcode-py.wisl.dev/problems/detect-squares) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/detect_squares/solution.py) |
| 2353 | [Design a Food Rating System](https://leetcode-py.wisl.dev/problems/design-a-food-rating-system) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_a_food_rating_system/solution.py) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.