Beautiful vertices

plz provide the code and explaination of the problem…

Not able to pass the sample test case Refer This.

i am not able to understand how to solve this problem …plz explain the apporach first and then code


why does this code show wrong answer plz reply and correct this code…as well…

Plz reply…to this doubt at the earliest

A node is considered beautiful if the number of children of that node is greater than the number of children of its parent node.
Consider a test case:
10 9
1 2
2 4
2 5
2 6
5 8
1 3
3 7
7 11
7 13
Correct output - 2 (Beautiful vertices are 2 and 7)
Your output - 1

Cross check your logic with this case.
You can also refer the approach from here https://ide.codingblocks.com/s/145247

&&j.first!=node
why is this line written in the code
what is its purpose??

in the question isnt it a directed graph?? if it is a directed graph then how would we solve it??
if we take the input as a directed graph then it shows correct output for testcases…but it is not getting submitted the…why is that so??
i think this code must work for directed as well…

A master parent cannot be a beautiful vertex so that condition is to ensure that you do not check the master parent(or the root node) for a beautiful vertex.

According to the question and the test cases ,the graph must be undirected. Traversal starts from the smallest node in that component. If you make a directed graph, there may be a case that all nodes in one component is not visited.

Consider a case:
3 2
0 1
2 1

Nodes 0,1 and 2 forms a single component.But if you consider it as a directed graph, in one traversal all nodes will not be visited. Node 2 will remain unvisited.

ok plz reply to this doubt of mine as well…no one has responded to it its been a week since i have posted it…plz reply now

Please post it as a new doubt. That doubt is not visible on our portal so that we can acknowledge.

this is a seperate doubt only…i have just shared its link …to you…you can click on it to view it

i have raised a new doubt regarding jack goes to rapture question
now reply on it …plz

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.