Skip to content

Commit 98a4540

Browse files
add comments for 1273
1 parent 7bf365e commit 98a4540

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/main/java/com/fishercoder/solutions/_1273.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ public int deleteTreeNodes(int nodes, int[] parent, int[] value) {
3838
while (i > 0 && parent[i] == parentIndex) {
3939
sum += value[i--];
4040
}
41+
//we'll reset the value to be the newly computed sum of this node and all of its children
4142
value[parentIndex] = value[parentIndex] + sum;
4243
}
44+
//then we'll reset this node's children to be zero if this node's computed sum is zero
4345
for (int i = 0; i < value.length; i++) {
4446
if (value[i] == 0) {
4547
for (int j = 0; j < parent.length; j++) {

0 commit comments

Comments
 (0)