We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d47ea5f commit 8571005Copy full SHA for 8571005
src/me/ramswaroop/trees/ChildrenSum.java
@@ -63,9 +63,9 @@ public static <E extends Comparable<E>> void toChildrenSum(BinaryNode<E> node) {
63
64
int diff = leftChildValue + rightChildValue - nodeValue;
65
66
- if (diff < 0) {
+ if (diff < 0) { // tricky: children sum is less
67
increment(node, -diff);
68
- } else if (diff > 0) {
+ } else if (diff > 0) { // simple: children sum is more, so just add the diff to parent node
69
//node.value += diff;
70
}
71
0 commit comments