File tree 1 file changed +0
-26
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-26
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import com .fishercoder .common .classes .TreeNode ;
4
4
5
- /**
6
- * 563. Binary Tree Tilt
7
- *
8
- * Given a binary tree, return the tilt of the whole tree.
9
- * The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values
10
- * and the sum of all right subtree node values.
11
- * Null node has tilt 0.
12
- * The tilt of the whole tree is defined as the sum of all nodes' tilt.
13
-
14
- Example:
15
- Input:
16
- 1
17
- / \
18
- 2 3
19
-
20
- Output: 1
21
-
22
- Explanation:
23
- Tilt of node 2 : 0
24
- Tilt of node 3 : 0
25
- Tilt of node 1 : |2-3| = 1
26
- Tilt of binary tree : 0 + 0 + 1 = 1
27
-
28
- Note:
29
- The sum of node values in any subtree won't exceed the range of 32-bit integer.
30
- All the tilt values won't exceed the range of 32-bit integer.*/
31
5
public class _563 {
32
6
public static class Solution1 {
33
7
You can’t perform that action at this time.
0 commit comments