23. Maximum Stone Removal
β GFG solution to the Maximum Stone Removal problem: find maximum number of removable stones sharing rows or columns using Union-Find and graph connectivity techniques. π
π§© Problem Description
π Examples
Example 1
Input: stones[][] = [[0, 0], [0, 1], [1, 0], [1, 2], [2, 1], [2, 2]]
Output: 5
Explanation: One way to remove 5 stones:
1. Remove [2, 2] (shares row with [2, 1])
2. Remove [2, 1] (shares column with [0, 1])
3. Remove [1, 2] (shares row with [1, 0])
4. Remove [1, 0] (shares column with [0, 0])
5. Remove [0, 1] (shares row with [0, 0])
Stone [0, 0] remains as it cannot be removed.Example 2
π Constraints
β
My Approach
Union-Find (DSU) Strategy
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated