Test case- 25 2 5 5 5 4 5 2 7 0 8 3 8 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1


#1

Can someone explain why its output will be 0 ? It has subtree(5-5) getting repeated.


#2

5->5 is not a subtree. A subtree from 5 comprises every node that can be traversed from 5. 5->5 is only a part of subtree.