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

# Union-Find in Python with Tests

> All 54 Union-Find LeetCode problems with tested Python solutions.

Union-Find holds 54 problems (33 Medium, 21 Hard).
Generate any of them into the current directory with `lcpy gen -n <number>`.

| # | Problem | Difficulty | Solution |
| - | - | - | - |
| 128 | [Longest Consecutive Sequence](https://leetcode-py.wisl.dev/problems/longest-consecutive-sequence) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/longest_consecutive_sequence/solution.py) |
| 130 | [Surrounded Regions](https://leetcode-py.wisl.dev/problems/surrounded-regions) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/surrounded_regions/solution.py) |
| 200 | [Number of Islands](https://leetcode-py.wisl.dev/problems/number-of-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_islands/solution.py) |
| 261 | [Graph Valid Tree](https://leetcode-py.wisl.dev/problems/graph-valid-tree) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/graph_valid_tree/solution.py) |
| 305 | [Number of Islands II](https://leetcode-py.wisl.dev/problems/number-of-islands-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_islands_ii/solution.py) |
| 323 | [Number of Connected Components in an Undirected Graph](https://leetcode-py.wisl.dev/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) |
| 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) |
| 399 | [Evaluate Division](https://leetcode-py.wisl.dev/problems/evaluate-division) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/evaluate_division/solution.py) |
| 547 | [Number of Provinces](https://leetcode-py.wisl.dev/problems/number-of-provinces) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_provinces/solution.py) |
| 684 | [Redundant Connection](https://leetcode-py.wisl.dev/problems/redundant-connection) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redundant_connection/solution.py) |
| 685 | [Redundant Connection II](https://leetcode-py.wisl.dev/problems/redundant-connection-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/redundant_connection_ii/solution.py) |
| 694 | [Number of Distinct Islands](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/accounts-merge) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/accounts_merge/solution.py) |
| 737 | [Sentence Similarity II](https://leetcode-py.wisl.dev/problems/sentence-similarity-ii) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/sentence_similarity_ii/solution.py) |
| 765 | [Couples Holding Hands](https://leetcode-py.wisl.dev/problems/couples-holding-hands) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/couples_holding_hands/solution.py) |
| 778 | [Swim in Rising Water](https://leetcode-py.wisl.dev/problems/swim-in-rising-water) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/swim_in_rising_water/solution.py) |
| 785 | [Is Graph Bipartite?](https://leetcode-py.wisl.dev/problems/is-graph-bipartite) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/is_graph_bipartite/solution.py) |
| 803 | [Bricks Falling When Hit](https://leetcode-py.wisl.dev/problems/bricks-falling-when-hit) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/bricks_falling_when_hit/solution.py) |
| 827 | [Making A Large Island](https://leetcode-py.wisl.dev/problems/making-a-large-island) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/making_a_large_island/solution.py) |
| 839 | [Similar String Groups](https://leetcode-py.wisl.dev/problems/similar-string-groups) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/similar_string_groups/solution.py) |
| 886 | [Possible Bipartition](https://leetcode-py.wisl.dev/problems/possible-bipartition) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/possible_bipartition/solution.py) |
| 924 | [Minimize Malware Spread](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/minimize-malware-spread-ii) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimize_malware_spread_ii/solution.py) |
| 947 | [Most Stones Removed with Same Row or Column](https://leetcode-py.wisl.dev/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) |
| 952 | [Largest Component Size by Common Factor](https://leetcode-py.wisl.dev/problems/largest-component-size-by-common-factor) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/largest_component_size_by_common_factor/solution.py) |
| 959 | [Regions Cut By Slashes](https://leetcode-py.wisl.dev/problems/regions-cut-by-slashes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/regions_cut_by_slashes/solution.py) |
| 990 | [Satisfiability of Equality Equations](https://leetcode-py.wisl.dev/problems/satisfiability-of-equality-equations) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/satisfiability_of_equality_equations/solution.py) |
| 1020 | [Number of Enclaves](https://leetcode-py.wisl.dev/problems/number-of-enclaves) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_enclaves/solution.py) |
| 1101 | [The Earliest Moment When Everyone Become Friends](https://leetcode-py.wisl.dev/problems/the-earliest-moment-when-everyone-become-friends) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/the_earliest_moment_when_everyone_become_friends/solution.py) |
| 1102 | [Path With Maximum Minimum Value](https://leetcode-py.wisl.dev/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) |
| 1135 | [Connecting Cities With Minimum Cost](https://leetcode-py.wisl.dev/problems/connecting-cities-with-minimum-cost) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/connecting_cities_with_minimum_cost/solution.py) |
| 1168 | [Optimize Water Distribution in a Village](https://leetcode-py.wisl.dev/problems/optimize-water-distribution-in-a-village) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/optimize_water_distribution_in_a_village/solution.py) |
| 1254 | [Number of Closed Islands](https://leetcode-py.wisl.dev/problems/number-of-closed-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_closed_islands/solution.py) |
| 1258 | [Synonymous Sentences](https://leetcode-py.wisl.dev/problems/synonymous-sentences) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/synonymous_sentences/solution.py) |
| 1267 | [Count Servers that Communicate](https://leetcode-py.wisl.dev/problems/count-servers-that-communicate) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_servers_that_communicate/solution.py) |
| 1361 | [Validate Binary Tree Nodes](https://leetcode-py.wisl.dev/problems/validate-binary-tree-nodes) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/validate_binary_tree_nodes/solution.py) |
| 1489 | [Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree](https://leetcode-py.wisl.dev/problems/find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_critical_and_pseudo_critical_edges_in_minimum_spanning_tree/solution.py) |
| 1579 | [Remove Max Number of Edges to Keep Graph Fully Traversable](https://leetcode-py.wisl.dev/problems/remove-max-number-of-edges-to-keep-graph-fully-traversable) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/remove_max_number_of_edges_to_keep_graph_fully_traversable/solution.py) |
| 1584 | [Min Cost to Connect All Points](https://leetcode-py.wisl.dev/problems/min-cost-to-connect-all-points) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/min_cost_to_connect_all_points/solution.py) |
| 1631 | [Path With Minimum Effort](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/count-sub-islands) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_sub_islands/solution.py) |
| 2092 | [Find All People With Secret](https://leetcode-py.wisl.dev/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) |
| 2421 | [Number of Good Paths](https://leetcode-py.wisl.dev/problems/number-of-good-paths) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/number_of_good_paths/solution.py) |
| 2492 | [Minimum Score of a Path Between Two Cities](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/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) |
| 2503 | [Maximum Number of Points From Grid Queries](https://leetcode-py.wisl.dev/problems/maximum-number-of-points-from-grid-queries) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/maximum_number_of_points_from_grid_queries/solution.py) |
| 2658 | [Maximum Number of Fish in a Grid](https://leetcode-py.wisl.dev/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](https://leetcode-py.wisl.dev/problems/count-complete-components) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/count_complete_components/solution.py) |
| 2709 | [Greatest Common Divisor Traversal](https://leetcode-py.wisl.dev/problems/greatest-common-divisor-traversal) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/greatest_common_divisor_traversal/solution.py) |
| 2812 | [Find the Safest Path in a Grid](https://leetcode-py.wisl.dev/problems/find-the-safest-path-in-a-grid) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/find_the_safest_path_in_a_grid/solution.py) |
| 2948 | [Make Lexicographically Smallest Array by Swapping Elements](https://leetcode-py.wisl.dev/problems/make-lexicographically-smallest-array-by-swapping-elements) | Medium | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/make_lexicographically_smallest_array_by_swapping_elements/solution.py) |
| 3108 | [Minimum Cost Walk in Weighted Graph](https://leetcode-py.wisl.dev/problems/minimum-cost-walk-in-weighted-graph) | Hard | [solution.py](https://github.com/wislertt/leetcode-py/blob/main/leetcode/minimum_cost_walk_in_weighted_graph/solution.py) |


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