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

# Binary Search Tree in Python with Tests

> All 31 Binary Search Tree LeetCode problems with tested Python solutions.

Binary Search Tree holds 31 problems (10 Easy, 20 Medium, 1 Hard).
Generate any of them into the current directory with `lcpy gen -n <number>`.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 95 | [Unique Binary Search Trees II](/problems/unique-binary-search-trees-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_binary_search_trees_ii/solution.py) |
  | 96 | [Unique Binary Search Trees](/problems/unique-binary-search-trees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/unique_binary_search_trees/solution.py) |
  | 98 | [Validate Binary Search Tree](/problems/validate-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/validate_binary_search_tree/solution.py) |
  | 99 | [Recover Binary Search Tree](/problems/recover-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/recover_binary_search_tree/solution.py) |
  | 108 | [Convert Sorted Array to Binary Search Tree](/problems/convert-sorted-array-to-binary-search-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_sorted_array_to_binary_search_tree/solution.py) |
  | 109 | [Convert Sorted List to Binary Search Tree](/problems/convert-sorted-list-to-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_sorted_list_to_binary_search_tree/solution.py) |
  | 173 | [Binary Search Tree Iterator](/problems/binary-search-tree-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_search_tree_iterator/solution.py) |
  | 230 | [Kth Smallest Element in a BST](/problems/kth-smallest-element-in-a-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kth_smallest_element_in_a_bst/solution.py) |
  | 235 | [Lowest Common Ancestor of a Binary Search Tree](/problems/lowest-common-ancestor-of-a-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lowest_common_ancestor_of_a_binary_search_tree/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) |
  | 270 | [Closest Binary Search Tree Value](/problems/closest-bst-value) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/closest_bst_value/solution.py) |
  | 272 | [Closest Binary Search Tree Value II](/problems/closest-bst-value-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/closest_bst_value_ii/solution.py) |
  | 285 | [Inorder Successor in BST](/problems/inorder-successor-in-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/inorder_successor_in_bst/solution.py) |
  | 333 | [Largest BST Subtree](/problems/largest-bst-subtree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_bst_subtree/solution.py) |
  | 426 | [Convert Binary Search Tree to Sorted Doubly Linked List](/problems/convert-binary-search-tree-to-sorted-doubly-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_binary_search_tree_to_sorted_doubly_linked_list/solution.py) |
  | 449 | [Serialize and Deserialize BST](/problems/serialize-and-deserialize-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_bst/solution.py) |
  | 450 | [Delete Node in a BST](/problems/delete-node-in-a-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_node_in_a_bst/solution.py) |
  | 501 | [Find Mode in Binary Search Tree](/problems/find-mode-in-binary-search-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_mode_in_binary_search_tree/solution.py) |
  | 510 | [Inorder Successor in BST II](/problems/inorder-successor-in-bst-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/inorder_successor_in_bst_ii/solution.py) |
  | 530 | [Minimum Absolute Difference in BST](/problems/minimum-absolute-difference-in-bst) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_absolute_difference_in_bst/solution.py) |
  | 538 | [Convert BST to Greater Tree](/problems/convert-bst-to-greater-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/convert_bst_to_greater_tree/solution.py) |
  | 653 | [Two Sum IV - Input is a BST](/problems/two-sum-iv-input-is-a-bst) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/two_sum_iv_input_is_a_bst/solution.py) |
  | 669 | [Trim a Binary Search Tree](/problems/trim-a-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/trim_a_binary_search_tree/solution.py) |
  | 700 | [Search in a Binary Search Tree](/problems/search-in-a-binary-search-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/search_in_a_binary_search_tree/solution.py) |
  | 701 | [Insert into a Binary Search Tree](/problems/insert-into-a-binary-search-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/insert_into_a_binary_search_tree/solution.py) |
  | 703 | [Kth Largest Element in a Stream](/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) |
  | 776 | [Split BST](/problems/split-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_bst/solution.py) |
  | 783 | [Minimum Distance Between BST Nodes](/problems/min-distance-in-bst) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/min_distance_in_bst/solution.py) |
  | 897 | [Increasing Order Search Tree](/problems/increasing-order-search-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/increasing_order_search_tree/solution.py) |
  | 938 | [Range Sum of BST](/problems/range-sum-of-bst) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/range_sum_of_bst/solution.py) |
  | 1214 | [Two Sum BSTs](/problems/two-sum-bsts) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/two_sum_bsts/solution.py) |
</div>


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