Skip to content

Commit 9f2456e

Browse files
committed
Runtime: 117 ms (Top 43.50%) | Memory: 47.8 MB (Top 17.51%)
1 parent d67a064 commit 9f2456e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
// Runtime: 117 ms (Top 43.50%) | Memory: 47.8 MB (Top 17.51%)
12
var findTilt = function(root) {
23
function helper(node, acc) {
34
if (node === null) {
45
return 0;
56
}
6-
7+
78
const left = helper(node.left, acc);
89
const right = helper(node.right, acc);
9-
10+
1011
acc.sum += Math.abs(left - right);
11-
12+
1213
return left + node.val + right;
1314
}
14-
15+
1516
let acc = { sum: 0 };
1617
helper(root, acc);
17-
18+
1819
return acc.sum;
19-
};
20+
};

0 commit comments

Comments
 (0)