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

| # | Problem | Difficulty | Solution |
| - | - | - | - |
| 42 | [Trapping Rain Water](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/remove-k-digits) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_k_digits/solution.py) |
| 456 | [132 Pattern](https://leetcode-py.wisl.dev/problems/pattern-132) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/pattern_132/solution.py) |
| 496 | [Next Greater Element I](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/maximum-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_binary_tree/solution.py) |
| 739 | [Daily Temperatures](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/car-fleet) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/car_fleet/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) |
| 907 | [Sum of Subarray Minimums](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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) |


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