A tree rooted at node 0 is given as follows:
- The number of nodes is nodes;
- The value of the ith node is value[i];
- The parent of the ith node is parent[i].
Remove every subtree whose sum of values of nodes is zero.
Return the number of the remaining nodes in the tree.
c++
1 | class Solution { |