Can't really understand what is going on in the question ... Amit and Tree

Hey …
I cant really get what is going on in the question and why certain test cases have such answer …
For eg …
9
59 48 48 14 51 51 86 53 58
2 1 -47
3 5 10
4 8 -6
5 9 46
6 2 -69
7 8 -79
8 9 92
9 6 12
this test case has answer of 5 …
I drew the tree for the case but can see only 4 nodes as the ans …
pls let me know what is actually going on in here
Maybe … I can share the tree …


This is the tree for the test case

@prabh1601
The tree is rooted at one
You have erased 1 here
You can only delete leaves
Please go through the question again maybe you misunderstood it

Pls have some mercy and get the photo opened man …
The pic that is showing here is not getting shown full …
Pls go through my query once more

@prabh1601
Sincere apologies buddy
I thought you uploaded the pic directly to this doubt in which case entire image is shown

Now coming to your query
If you see here you will end up removing nodes 3, 4, 5, 7, 8
The reason begin distance between 8 and 9
and 5 and 9 is greater than allowed making it unbalanced
So you need to remove those nodes for which you need to remove their children nodes as well

Hope this resolved your doubt

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.