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

# Depth-First Search in Python with Tests

> All 200 Depth-First Search LeetCode problems with tested Python solutions.

Depth-First Search holds 200 problems (34 Easy, 132 Medium, 34 Hard).
Generate any of them into the current directory with `lcpy gen -n <number>`.

<div className="sd-catalog-table">
  | # | Problem | Difficulty | Solution |
  | - | - | - | - |
  | 79 | [Word Search](/problems/word-search) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/word_search/solution.py) |
  | 94 | [Binary Tree Inorder Traversal](/problems/binary-tree-inorder-traversal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_inorder_traversal/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) |
  | 100 | [Same Tree](/problems/same-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/same_tree/solution.py) |
  | 101 | [Symmetric Tree](/problems/symmetric-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/symmetric_tree/solution.py) |
  | 104 | [Maximum Depth of Binary Tree](/problems/maximum-depth-of-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_depth_of_binary_tree/solution.py) |
  | 110 | [Balanced Binary Tree](/problems/balanced-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/balanced_binary_tree/solution.py) |
  | 111 | [Minimum Depth of Binary Tree](/problems/minimum-depth-of-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_depth_of_binary_tree/solution.py) |
  | 112 | [Path Sum](/problems/path-sum) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum/solution.py) |
  | 113 | [Path Sum II](/problems/path-sum-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum_ii/solution.py) |
  | 114 | [Flatten Binary Tree to Linked List](/problems/flatten-binary-tree-to-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_binary_tree_to_linked_list/solution.py) |
  | 116 | [Populating Next Right Pointers In Each Node](/problems/populating-next-right-pointers-in-each-node) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/populating_next_right_pointers_in_each_node/solution.py) |
  | 117 | [Populating Next Right Pointers in Each Node II](/problems/populating-next-right-pointers-in-each-node-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/populating_next_right_pointers_in_each_node_ii/solution.py) |
  | 124 | [Binary Tree Maximum Path Sum](/problems/binary-tree-maximum-path-sum) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_maximum_path_sum/solution.py) |
  | 129 | [Sum Root to Leaf Numbers](/problems/sum-root-to-leaf-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_root_to_leaf_numbers/solution.py) |
  | 130 | [Surrounded Regions](/problems/surrounded-regions) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/surrounded_regions/solution.py) |
  | 133 | [Clone Graph](/problems/clone-graph) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/clone_graph/solution.py) |
  | 144 | [Binary Tree Preorder Traversal](/problems/binary-tree-preorder-traversal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_preorder_traversal/solution.py) |
  | 145 | [Binary Tree Postorder Traversal](/problems/binary-tree-postorder-traversal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_postorder_traversal/solution.py) |
  | 156 | [Binary Tree Upside Down](/problems/binary-tree-upside-down) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_upside_down/solution.py) |
  | 199 | [Binary Tree Right Side View](/problems/binary-tree-right-side-view) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_right_side_view/solution.py) |
  | 200 | [Number of Islands](/problems/number-of-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_islands/solution.py) |
  | 207 | [Course Schedule](/problems/course-schedule) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/course_schedule/solution.py) |
  | 210 | [Course Schedule II](/problems/course-schedule-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/course_schedule_ii/solution.py) |
  | 211 | [Design Add and Search Words Data Structure](/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) |
  | 226 | [Invert Binary Tree](/problems/invert-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/invert_binary_tree/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) |
  | 236 | [Lowest Common Ancestor of a Binary Tree](/problems/lowest-common-ancestor-of-a-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lowest_common_ancestor_of_a_binary_tree/solution.py) |
  | 250 | [Count Univalue Subtrees](/problems/count-univalue-subtrees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_univalue_subtrees/solution.py) |
  | 257 | [Binary Tree Paths](/problems/binary-tree-paths) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_paths/solution.py) |
  | 261 | [Graph Valid Tree](/problems/graph-valid-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/graph_valid_tree/solution.py) |
  | 269 | [Alien Dictionary](/problems/alien-dictionary) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/alien_dictionary/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) |
  | 297 | [Serialize and Deserialize Binary Tree](/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) |
  | 298 | [Binary Tree Longest Consecutive Sequence](/problems/binary-tree-longest-consecutive-sequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_longest_consecutive_sequence/solution.py) |
  | 302 | [Smallest Rectangle Enclosing Black Pixels](/problems/smallest-rectangle-enclosing-black-pixels) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_rectangle_enclosing_black_pixels/solution.py) |
  | 310 | [Minimum Height Trees](/problems/minimum-height-trees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_height_trees/solution.py) |
  | 314 | [Binary Tree Vertical Order Traversal](/problems/binary-tree-vertical-order-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_vertical_order_traversal/solution.py) |
  | 323 | [Number of Connected Components in an Undirected Graph](/problems/number-of-connected-components-in-an-undirected-graph) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_connected_components_in_an_undirected_graph/solution.py) |
  | 329 | [Longest Increasing Path in a Matrix](/problems/longest-increasing-path-in-a-matrix) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_increasing_path_in_a_matrix/solution.py) |
  | 332 | [Reconstruct Itinerary](/problems/reconstruct-itinerary) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reconstruct_itinerary/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) |
  | 337 | [House Robber III](/problems/house-robber-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/house_robber_iii/solution.py) |
  | 339 | [Nested List Weight Sum](/problems/nested-list-weight-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/nested_list_weight_sum/solution.py) |
  | 341 | [Flatten Nested List Iterator](/problems/flatten-nested-list-iterator) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_nested_list_iterator/solution.py) |
  | 364 | [Nested List Weight Sum II](/problems/nested-list-weight-sum-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/nested_list_weight_sum_ii/solution.py) |
  | 365 | [Water and Jug Problem](/problems/water-and-jug-problem) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/water_and_jug_problem/solution.py) |
  | 366 | [Find Leaves of Binary Tree](/problems/find-leaves-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_leaves_of_binary_tree/solution.py) |
  | 385 | [Mini Parser](/problems/mini-parser) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/mini_parser/solution.py) |
  | 386 | [Lexicographical Numbers](/problems/lexicographical-numbers) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/lexicographical_numbers/solution.py) |
  | 388 | [Longest Absolute File Path](/problems/longest-absolute-file-path) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_absolute_file_path/solution.py) |
  | 399 | [Evaluate Division](/problems/evaluate-division) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/evaluate_division/solution.py) |
  | 404 | [Sum of Left Leaves](/problems/sum-of-left-leaves) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_left_leaves/solution.py) |
  | 417 | [Pacific Atlantic Water Flow](/problems/pacific-atlantic-water-flow) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/pacific_atlantic_water_flow/solution.py) |
  | 419 | [Battleships in a Board](/problems/battleships-in-a-board) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/battleships_in_a_board/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) |
  | 428 | [Serialize and Deserialize N-ary Tree](/problems/serialize-and-deserialize-n-ary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/serialize_and_deserialize_n_ary_tree/solution.py) |
  | 430 | [Flatten a Multilevel Doubly Linked List](/problems/flatten-a-multilevel-doubly-linked-list) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flatten_a_multilevel_doubly_linked_list/solution.py) |
  | 431 | [Encode N-ary Tree to Binary Tree](/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) |
  | 437 | [Path Sum III](/problems/path-sum-iii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum_iii/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) |
  | 463 | [Island Perimeter](/problems/island-perimeter) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/island_perimeter/solution.py) |
  | 472 | [Concatenated Words](/problems/concatenated-words) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/concatenated_words/solution.py) |
  | 490 | [The Maze](/problems/the-maze) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_maze/solution.py) |
  | 499 | [The Maze III](/problems/the-maze-iii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_maze_iii/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) |
  | 505 | [The Maze II](/problems/the-maze-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_maze_ii/solution.py) |
  | 508 | [Most Frequent Subtree Sum](/problems/most-frequent-subtree-sum) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/most_frequent_subtree_sum/solution.py) |
  | 513 | [Find Bottom Left Tree Value](/problems/find-bottom-left-tree-value) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_bottom_left_tree_value/solution.py) |
  | 514 | [Freedom Trail](/problems/freedom-trail) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/freedom_trail/solution.py) |
  | 515 | [Find Largest Value in Each Tree Row](/problems/find-largest-value-in-each-tree-row) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_largest_value_in_each_tree_row/solution.py) |
  | 529 | [Minesweeper](/problems/minesweeper) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minesweeper/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) |
  | 536 | [Construct Binary Tree from String](/problems/construct-binary-tree-from-string) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_binary_tree_from_string/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) |
  | 543 | [Diameter of Binary Tree](/problems/diameter-of-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/diameter_of_binary_tree/solution.py) |
  | 545 | [Boundary of Binary Tree](/problems/boundary-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/boundary_of_binary_tree/solution.py) |
  | 547 | [Number of Provinces](/problems/number-of-provinces) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_provinces/solution.py) |
  | 549 | [Binary Tree Longest Consecutive Sequence II](/problems/binary-tree-longest-consecutive-sequence-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_longest_consecutive_sequence_ii/solution.py) |
  | 559 | [Maximum Depth of N-ary Tree](/problems/maximum-depth-of-n-ary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_depth_of_n_ary_tree/solution.py) |
  | 563 | [Binary Tree Tilt](/problems/binary-tree-tilt) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_tilt/solution.py) |
  | 565 | [Array Nesting](/problems/array-nesting) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/array_nesting/solution.py) |
  | 572 | [Subtree of Another Tree](/problems/subtree-of-another-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/subtree_of_another_tree/solution.py) |
  | 582 | [Kill Process](/problems/kill-process) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/kill_process/solution.py) |
  | 589 | [N-ary Tree Preorder Traversal](/problems/n-ary-tree-preorder-traversal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/n_ary_tree_preorder_traversal/solution.py) |
  | 590 | [N-ary Tree Postorder Traversal](/problems/n-ary-tree-postorder-traversal) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/n_ary_tree_postorder_traversal/solution.py) |
  | 606 | [Construct String from Binary Tree](/problems/construct-string-from-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/construct_string_from_binary_tree/solution.py) |
  | 617 | [Merge Two Binary Trees](/problems/merge-two-binary-trees) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/merge_two_binary_trees/solution.py) |
  | 623 | [Add One Row to Tree](/problems/add-one-row-to-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/add_one_row_to_tree/solution.py) |
  | 637 | [Average of Levels in Binary Tree](/problems/average-of-levels-in-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/average_of_levels_in_binary_tree/solution.py) |
  | 642 | [Design Search Autocomplete System](/problems/design-search-autocomplete-system) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/design_search_autocomplete_system/solution.py) |
  | 652 | [Find Duplicate Subtrees](/problems/find-duplicate-subtrees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_duplicate_subtrees/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) |
  | 655 | [Print Binary Tree](/problems/print-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/print_binary_tree/solution.py) |
  | 662 | [Maximum Width of Binary Tree](/problems/maximum-width-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_width_of_binary_tree/solution.py) |
  | 663 | [Equal Tree Partition](/problems/equal-tree-partition) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/equal_tree_partition/solution.py) |
  | 666 | [Path Sum IV](/problems/path-sum-iv) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_sum_iv/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) |
  | 671 | [Second Minimum Node In a Binary Tree](/problems/second-minimum-node-in-a-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/second_minimum_node_in_a_binary_tree/solution.py) |
  | 672 | [Bulb Switcher II](/problems/bulb-switcher-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bulb_switcher_ii/solution.py) |
  | 676 | [Implement Magic Dictionary](/problems/implement-magic-dictionary) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/implement_magic_dictionary/solution.py) |
  | 684 | [Redundant Connection](/problems/redundant-connection) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redundant_connection/solution.py) |
  | 685 | [Redundant Connection II](/problems/redundant-connection-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redundant_connection_ii/solution.py) |
  | 687 | [Longest Univalue Path](/problems/longest-univalue-path) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_univalue_path/solution.py) |
  | 690 | [Employee Importance](/problems/employee-importance) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/employee_importance/solution.py) |
  | 694 | [Number of Distinct Islands](/problems/number-of-distinct-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_distinct_islands/solution.py) |
  | 695 | [Max Area of Island](/problems/max-area-of-island) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/max_area_of_island/solution.py) |
  | 711 | [Number of Distinct Islands II](/problems/number-of-distinct-islands-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_distinct_islands_ii/solution.py) |
  | 721 | [Accounts Merge](/problems/accounts-merge) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/accounts_merge/solution.py) |
  | 733 | [Flood Fill](/problems/flood-fill) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flood_fill/solution.py) |
  | 737 | [Sentence Similarity II](/problems/sentence-similarity-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sentence_similarity_ii/solution.py) |
  | 742 | [Closest Leaf in a Binary Tree](/problems/closest-leaf-in-a-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/closest_leaf_in_a_binary_tree/solution.py) |
  | 743 | [Network Delay Time](/problems/network-delay-time) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/network_delay_time/solution.py) |
  | 749 | [Contain Virus](/problems/contain-virus) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/contain_virus/solution.py) |
  | 753 | [Cracking the Safe](/problems/cracking-the-safe) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cracking_the_safe/solution.py) |
  | 765 | [Couples Holding Hands](/problems/couples-holding-hands) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/couples_holding_hands/solution.py) |
  | 776 | [Split BST](/problems/split-bst) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/split_bst/solution.py) |
  | 778 | [Swim in Rising Water](/problems/swim-in-rising-water) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/swim_in_rising_water/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) |
  | 785 | [Is Graph Bipartite?](/problems/is-graph-bipartite) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/is_graph_bipartite/solution.py) |
  | 787 | [Cheapest Flights Within K Stops](/problems/cheapest-flights-within-k-stops) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cheapest_flights_within_k_stops/solution.py) |
  | 797 | [All Paths From Source to Target](/problems/all-paths-source-target) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/all_paths_source_target/solution.py) |
  | 802 | [Find Eventual Safe States](/problems/find-eventual-safe-states) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_eventual_safe_states/solution.py) |
  | 814 | [Binary Tree Pruning](/problems/binary-tree-pruning) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_pruning/solution.py) |
  | 827 | [Making A Large Island](/problems/making-a-large-island) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/making_a_large_island/solution.py) |
  | 834 | [Sum of Distances in Tree](/problems/sum-of-distances-in-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sum_of_distances_in_tree/solution.py) |
  | 839 | [Similar String Groups](/problems/similar-string-groups) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/similar_string_groups/solution.py) |
  | 841 | [Keys and Rooms](/problems/keys-and-rooms) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/keys_and_rooms/solution.py) |
  | 851 | [Loud and Rich](/problems/loud-and-rich) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/loud_and_rich/solution.py) |
  | 863 | [All Nodes Distance K in Binary Tree](/problems/all-nodes-distance-k-in-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/all_nodes_distance_k_in_binary_tree/solution.py) |
  | 865 | [Smallest Subtree with all the Deepest Nodes](/problems/smallest-subtree-with-all-the-deepest-nodes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_subtree_with_all_the_deepest_nodes/solution.py) |
  | 872 | [Leaf-Similar Trees](/problems/leaf-similar-trees) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/leaf_similar_trees/solution.py) |
  | 886 | [Possible Bipartition](/problems/possible-bipartition) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/possible_bipartition/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) |
  | 924 | [Minimize Malware Spread](/problems/minimize-malware-spread) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimize_malware_spread/solution.py) |
  | 928 | [Minimize Malware Spread II](/problems/minimize-malware-spread-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimize_malware_spread_ii/solution.py) |
  | 934 | [Shortest Bridge](/problems/shortest-bridge) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/shortest_bridge/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) |
  | 947 | [Most Stones Removed with Same Row or Column](/problems/most-stones-removed-with-same-row-or-column) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/most_stones_removed_with_same_row_or_column/solution.py) |
  | 951 | [Flip Equivalent Binary Trees](/problems/flip-equivalent-binary-trees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flip_equivalent_binary_trees/solution.py) |
  | 959 | [Regions Cut By Slashes](/problems/regions-cut-by-slashes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/regions_cut_by_slashes/solution.py) |
  | 965 | [Univalued Binary Tree](/problems/univalued-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/univalued_binary_tree/solution.py) |
  | 968 | [Binary Tree Cameras](/problems/binary-tree-cameras) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/binary_tree_cameras/solution.py) |
  | 971 | [Flip Binary Tree To Match Preorder Traversal](/problems/flip-binary-tree-to-match-preorder-traversal) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/flip_binary_tree_to_match_preorder_traversal/solution.py) |
  | 979 | [Distribute Coins in Binary Tree](/problems/distribute-coins-in-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/distribute_coins_in_binary_tree/solution.py) |
  | 987 | [Vertical Order Traversal of a Binary Tree](/problems/vertical-order-traversal-of-a-binary-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/vertical_order_traversal_of_a_binary_tree/solution.py) |
  | 988 | [Smallest String Starting From Leaf](/problems/smallest-string-starting-from-leaf) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/smallest_string_starting_from_leaf/solution.py) |
  | 993 | [Cousins in Binary Tree](/problems/cousins-in-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cousins_in_binary_tree/solution.py) |
  | 1020 | [Number of Enclaves](/problems/number-of-enclaves) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_enclaves/solution.py) |
  | 1028 | [Recover a Tree From Preorder Traversal](/problems/recover-a-tree-from-preorder-traversal) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/recover_a_tree_from_preorder_traversal/solution.py) |
  | 1059 | [All Paths from Source Lead to Destination](/problems/all-paths-from-source-lead-to-destination) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/all_paths_from_source_lead_to_destination/solution.py) |
  | 1088 | [Confusing Number II](/problems/confusing-number-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/confusing_number_ii/solution.py) |
  | 1102 | [Path With Maximum Minimum Value](/problems/path-with-maximum-minimum-value) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_with_maximum_minimum_value/solution.py) |
  | 1110 | [Delete Nodes And Return Forest](/problems/delete-nodes-and-return-forest) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_nodes_and_return_forest/solution.py) |
  | 1120 | [Maximum Average Subtree](/problems/maximum-average-subtree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_average_subtree/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) |
  | 1233 | [Remove Sub-Folders from the Filesystem](/problems/remove-sub-folders-from-the-filesystem) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_sub_folders_from_the_filesystem/solution.py) |
  | 1236 | [Web Crawler](/problems/web-crawler) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/web_crawler/solution.py) |
  | 1245 | [Tree Diameter](/problems/tree-diameter) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/tree_diameter/solution.py) |
  | 1254 | [Number of Closed Islands](/problems/number-of-closed-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_closed_islands/solution.py) |
  | 1267 | [Count Servers that Communicate](/problems/count-servers-that-communicate) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_servers_that_communicate/solution.py) |
  | 1273 | [Delete Tree Nodes](/problems/delete-tree-nodes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_tree_nodes/solution.py) |
  | 1325 | [Delete Leaves With a Given Value](/problems/delete-leaves-with-a-given-value) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/delete_leaves_with_a_given_value/solution.py) |
  | 1361 | [Validate Binary Tree Nodes](/problems/validate-binary-tree-nodes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/validate_binary_tree_nodes/solution.py) |
  | 1367 | [Linked List in Binary Tree](/problems/linked-list-in-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/linked_list_in_binary_tree/solution.py) |
  | 1376 | [Time Needed to Inform All Employees](/problems/time-needed-to-inform-all-employees) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/time_needed_to_inform_all_employees/solution.py) |
  | 1443 | [Minimum Time to Collect All Apples in a Tree](/problems/minimum-time-to-collect-all-apples-in-a-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_time_to_collect_all_apples_in_a_tree/solution.py) |
  | 1448 | [Count Good Nodes in Binary Tree](/problems/count-good-nodes-in-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_good_nodes_in_binary_tree/solution.py) |
  | 1457 | [Pseudo-Palindromic Paths in a Binary Tree](/problems/pseudo-palindromic-paths-in-a-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/pseudo_palindromic_paths_in_a_binary_tree/solution.py) |
  | 1462 | [Course Schedule IV](/problems/course-schedule-iv) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/course_schedule_iv/solution.py) |
  | 1466 | [Reorder Routes to Make All Paths Lead to the City Zero](/problems/reorder-routes-to-make-all-paths-lead-to-the-city-zero) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reorder_routes_to_make_all_paths_lead_to_the_city_zero/solution.py) |
  | 1490 | [Clone N-ary Tree](/problems/clone-n-ary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/clone_n_ary_tree/solution.py) |
  | 1506 | [Find Root of N-Ary Tree](/problems/find-root-of-n-ary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_root_of_n_ary_tree/solution.py) |
  | 1522 | [Diameter of N-Ary Tree](/problems/diameter-of-n-ary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/diameter_of_n_ary_tree/solution.py) |
  | 1530 | [Number of Good Leaf Nodes Pairs](/problems/number-of-good-leaf-nodes-pairs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_good_leaf_nodes_pairs/solution.py) |
  | 1568 | [Minimum Number of Days to Disconnect Island](/problems/minimum-number-of-days-to-disconnect-island) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_number_of_days_to_disconnect_island/solution.py) |
  | 1631 | [Path With Minimum Effort](/problems/path-with-minimum-effort) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/path_with_minimum_effort/solution.py) |
  | 1905 | [Count Sub Islands](/problems/count-sub-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_sub_islands/solution.py) |
  | 1993 | [Operations on Tree](/problems/operations-on-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/operations_on_tree/solution.py) |
  | 2092 | [Find All People With Secret](/problems/find-all-people-with-secret) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_all_people_with_secret/solution.py) |
  | 2096 | [Step-By-Step Directions From a Binary Tree Node to Another](/problems/step-by-step-directions-from-a-binary-tree-node-to-another) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/step_by_step_directions_from_a_binary_tree_node_to_another/solution.py) |
  | 2101 | [Detonate the Maximum Bombs](/problems/detonate-the-maximum-bombs) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/detonate_the_maximum_bombs/solution.py) |
  | 2127 | [Maximum Employees to Be Invited to a Meeting](/problems/maximum-employees-to-be-invited-to-a-meeting) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_employees_to_be_invited_to_a_meeting/solution.py) |
  | 2331 | [Evaluate Boolean Binary Tree](/problems/evaluate-boolean-binary-tree) | Easy | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/evaluate_boolean_binary_tree/solution.py) |
  | 2359 | [Find Closest Node to Given Two Nodes](/problems/find-closest-node-to-given-two-nodes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_closest_node_to_given_two_nodes/solution.py) |
  | 2415 | [Reverse Odd Levels of Binary Tree](/problems/reverse-odd-levels-of-binary-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/reverse_odd_levels_of_binary_tree/solution.py) |
  | 2467 | [Most Profitable Path in a Tree](/problems/most-profitable-path-in-a-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/most_profitable_path_in_a_tree/solution.py) |
  | 2477 | [Minimum Fuel Cost to Report to the Capital](/problems/minimum-fuel-cost-to-report-to-the-capital) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_fuel_cost_to_report_to_the_capital/solution.py) |
  | 2492 | [Minimum Score of a Path Between Two Cities](/problems/minimum-score-of-a-path-between-two-cities) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_score_of_a_path_between_two_cities/solution.py) |
  | 2493 | [Divide Nodes Into the Maximum Number of Groups](/problems/divide-nodes-into-the-maximum-number-of-groups) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/divide_nodes_into_the_maximum_number_of_groups/solution.py) |
  | 2641 | [Cousins in Binary Tree II](/problems/cousins-in-binary-tree-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/cousins_in_binary_tree_ii/solution.py) |
  | 2658 | [Maximum Number of Fish in a Grid](/problems/maximum-number-of-fish-in-a-grid) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_number_of_fish_in_a_grid/solution.py) |
  | 2685 | [Count the Number of Complete Components](/problems/count-complete-components) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_complete_components/solution.py) |
  | 2872 | [Maximum Number of K-Divisible Components](/problems/maximum-number-of-k-divisible-components) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_number_of_k_divisible_components/solution.py) |
  | 3203 | [Find Minimum Diameter After Merging Two Trees](/problems/find-minimum-diameter-after-merging-two-trees) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_minimum_diameter_after_merging_two_trees/solution.py) |
  | 3481 | [Apply Substitutions](/problems/apply-substitutions) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/apply_substitutions/solution.py) |
</div>


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