Beautiful Vertices

Passes Sample test case but fails other test cases!!!
Please reply asap

@mohammadabdullahjawwad
There can be more than 1 connect component in graph. Consider this testcase
8 6
1 2
2 3
2 4
5 6
6 7
6 8
Here ans should be 2(node 2 and node 6) but your code is giving 1 because you have not considered all connect component.

Can you please help me with the implementation for above

As I can see you got 100 points. I am marking it as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.