Biggest Friend Group
Problem Explanation
In this problem you are given the number of nodes and M number of connections. You have to find the size of the largest connected component.
Logic
If we enter all the nodes in a DSU. All the nodes in the same connected component will have the same leader. So we can count the number of nodes with the same leader in the array. We can do this by taking an array of size n. We can initialize this array with 0. And increment the index of the leader every time it is encountered in and array. After this we end up with the size of all the connected components. Now we can find out the max size from this array.