SOLVE
LATER
There are N students and M relationships of the form u v, which means that student u and student v are friends. If two students are not friends directly but they have a mutual friend, then they too become friends. Your task is to count the number of friends of the \(i^{th}\) student where \(1 \leq i \leq N\).
Input:
The first line consists of two integers N and M denoting the number of students and the number of relationships respectively.
The next M lines consists of two integers u and v denoting that student u and student v are friends. u and v can never be equal and relationships are not repeated.
Output:
Print N space separated integers which tells us the number of friends of the \(i^{th}\) student.
Constraints:
\(1 \leq N \leq 10^5\)
\(1 \leq M \leq 10^5\)
\(1 \leq u, v \leq N\)
For the sample test case -
Student 1 has no friends.
Student 2 is friends with student 3 and 4.
Student 3 is friends with student 2 and 4.
Student 4 is friends with student 2 and 3.
Challenge Name
Code Monk (Disjoint Set Union (Union Find))
Code Monk (Disjoint Set Union (Union Find))