How did we know that union-find would work here? Real Intuition
\nReading the question gives no clue how we can start approaching this problem. So like an actual problem solver we pick up pen-paper. \nLet\'s consider the fol
![image](https://assets.leetcode.com/users/images/888d595b-036c-4fb7-a7b3-cac2c0a9b92f_1659806922.186965.jpeg)\nReading the question gives no clue how we can start approaching this problem. So like an actual problem solver we pick up pen-paper. \nLet\'s consider the following points of a 2 x 2 grid\n\nDEA, AFB, BGC, CHD are 4 initial edges\n\n```\nA     E     D\nF           H\nB     G     C\n```\n\nE being the midpoint of edge AD\nF being the midpoint of edge AB and so on\n\nWe join EF, then FG then GH and then HE and at each stage we notice --> connecting the already connected increases the number of regions by 1 ( joining is equivalent to having a slash there)\n\nHow can we know that 2 points are already connected? How can we remember whether 2 points have a relationship between them? Oh union- find helps with the same. Viola!
['Union Find']