> ## 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.

# Monotonic Stack in Python with Tests

> All 31 Monotonic Stack LeetCode problems with tested Python solutions.

Monotonic Stack holds 31 problems (2 Easy, 18 Medium, 11 Hard).
Generate any of them into the current directory with `lcpy gen -n <number>`.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 42 | [Trapping Rain Water](/problems/trapping-rain-water) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/trapping_rain_water/solution.py) |
  | 84 | [Largest Rectangle in Histogram](/problems/largest-rectangle-in-histogram) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_rectangle_in_histogram/solution.py) |
  | 85 | [Maximal Rectangle](/problems/maximal-rectangle) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximal_rectangle/solution.py) |
  | 255 | [Verify Preorder Sequence in Binary Search Tree](/problems/verify-preorder-sequence-in-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/verify_preorder_sequence_in_binary_search_tree/solution.py) |
  | 316 | [Remove Duplicate Letters](/problems/remove-duplicate-letters) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_duplicate_letters/solution.py) |
  | 321 | [Create Maximum Number](/problems/create-maximum-number) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/create_maximum_number/solution.py) |
  | 402 | [Remove K Digits](/problems/remove-k-digits) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_k_digits/solution.py) |
  | 456 | [132 Pattern](/problems/pattern-132) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/pattern_132/solution.py) |
  | 496 | [Next Greater Element I](/problems/next-greater-element-i) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/next_greater_element_i/solution.py) |
  | 503 | [Next Greater Element II](/problems/next-greater-element-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/next_greater_element_ii/solution.py) |
  | 581 | [Shortest Unsorted Continuous Subarray](/problems/shortest-unsorted-continuous-subarray) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_unsorted_continuous_subarray/solution.py) |
  | 654 | [Maximum Binary Tree](/problems/maximum-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_binary_tree/solution.py) |
  | 739 | [Daily Temperatures](/problems/daily-temperatures) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/daily_temperatures/solution.py) |
  | 768 | [Max Chunks To Make Sorted II](/problems/max-chunks-to-make-sorted-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_chunks_to_make_sorted_ii/solution.py) |
  | 769 | [Max Chunks To Make Sorted](/problems/max-chunks-to-make-sorted) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_chunks_to_make_sorted/solution.py) |
  | 853 | [Car Fleet](/problems/car-fleet) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/car_fleet/solution.py) |
  | 901 | [Online Stock Span](/problems/online-stock-span) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/online_stock_span/solution.py) |
  | 907 | [Sum of Subarray Minimums](/problems/sum-of-subarray-minimums) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_subarray_minimums/solution.py) |
  | 962 | [Maximum Width Ramp](/problems/maximum-width-ramp) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_width_ramp/solution.py) |
  | 975 | [Odd Even Jump](/problems/odd-even-jumps) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/odd_even_jumps/solution.py) |
  | 1475 | [Final Prices With a Special Discount in a Shop](/problems/final-prices-with-a-special-discount-in-a-shop) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/final_prices_with_a_special_discount_in_a_shop/solution.py) |
  | 1526 | [Minimum Number of Increments on Subarrays to Form a Target Array](/problems/minimum-number-of-increments-on-subarrays-to-form-a-target-array) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_increments_on_subarrays_to_form_a_target_array/solution.py) |
  | 1574 | [Shortest Subarray to be Removed to Make Array Sorted](/problems/shortest-subarray-to-be-removed-to-make-array-sorted) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_subarray_to_be_removed_to_make_array_sorted/solution.py) |
  | 1762 | [Buildings With an Ocean View](/problems/buildings-with-an-ocean-view) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/buildings_with_an_ocean_view/solution.py) |
  | 1793 | [Maximum Score of a Good Subarray](/problems/maximum-score-of-a-good-subarray) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_score_of_a_good_subarray/solution.py) |
  | 1856 | [Maximum Subarray Min-Product](/problems/maximum-subarray-min-product) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_subarray_min_product/solution.py) |
  | 1944 | [Number of Visible People in a Queue](/problems/number-of-visible-people-in-a-queue) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_visible_people_in_a_queue/solution.py) |
  | 1966 | [Binary Searchable Numbers in an Unsorted Array](/problems/binary-searchable-numbers-in-an-unsorted-array) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_searchable_numbers_in_an_unsorted_array/solution.py) |
  | 2487 | [Remove Nodes From Linked List](/problems/remove-nodes-from-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_nodes_from_linked_list/solution.py) |
  | 2818 | [Apply Operations to Maximize Score](/problems/apply-operations-to-maximize-score) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/apply_operations_to_maximize_score/solution.py) |
  | 2940 | [Find Building Where Alice and Bob Can Meet](/problems/find-building-where-alice-and-bob-can-meet) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_building_where_alice_and_bob_can_meet/solution.py) |
</div>


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