I am unable to find mistake in my code .
It is only passing sample test cases .
Rest are WA.
Plz Help!!!
My code is written here:-https://ide.codingblocks.com/s/148653
Happy vertices in hackerearth
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.
Nobody replied to my doubt and you are telling “I hope I’ve cleared your doubt.”
How?
I have still doubt in this question.
You will be responded soon here.
@Bhawna Can you post the question link as well because I think you have chosen the wrong category here.
@Bhawna
There’s no need to the BFS traversal. Just complete the DFS traversal and store the no of children for each node in a separate map/ array. After doing the complete DFS traversal of the entire graph , count the total no of nodes that have more children than their parents and that would be your final answer.
Kindly have a look at this code - https://ide.codingblocks.com/s/181505