LeetCode 947 Most Stones Removed with Same Row or Column - Why Naive Fails

The trap

Try all possible removal orders and count the maximum removals.

With nn stones, there are n!n! orderings to try. Each removal check requires verifying shared row/column with remaining stones.

Can you identify which stones must stay without simulating removals?