here is my code
https://ide.codingblocks.com/s/249802
I am not able to understand question beautiful vertices
A node is considered a beautiful if the number of children of that node is greater than the number of children of its parent node.Master parent cannot be a beautiful vertex.
Consider a test case:
5 4
1 2
1 3
3 4
3 5
Expected Output:
0. Here node 3 is not beautiful because node 3 has 2 children and its parent 1 also has 2 children.
Idea is to do DFS for each component. Store number of child for each node in a map. Also make a parent map and then check for the condition.
Refer this if you want to check the implementation Not able to pass the sample test case
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.