Beautiful_vertices

my code is passing sample test case but failing for others. Kindly tell where i am wrong.

check for this
6 5
1 2
1 3
2 3
3 4
3 5
output is 0 ur code gave 1
children should strictly greater than parent

@phantom

yes i corrected that, but still it is failing while submitting.

that a bad example
the limit of the question is the graph has no loop
the error is that u r not checking for the different components of the graph

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.