please help me to find the mistake in the code
The link to the code is :-
please help me to find the mistake in the code
The link to the code is :-
@krikhi for beautiful vertex, 2 conditions needs to be fulfilled - one is more number of children that parent, and you can also need to have a check if it is master parent or not.
A better way to solve and finally calculate the answer is, store for every node parent[node] and childs[node], for source parent[source]=-1.
At last check for every node :
if(parent[node]!=-1 && childs[node] > childs[parent[node]]) then count++
I have changed my code still testcases are not getting passed. the link to the code is :- https://ide.codingblocks.com/s/231238 please help me to find the mistake
@krikhi it was meant to be implemented through DFS.
Please once have a look at the hint video for this question, there you will be able to understand it properly. After watching you can ask any doubt you have in implementing that.
You can also have a look at this code if you want, i have done the required additions in your previous code, link-> https://ide.codingblocks.com/s/231241