Practice Binary Tree Tilt
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between the sum of all left subtree node values and all right subtree node values. If a node does not have a left child, then the sum of the left subtree node values is treated as 0. The rule is similar if the node does not have a right child.
Source: Binary Tree Tilt on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
root = [1,2,3]
1
# Example 2
root = [4,2,9,3,5,null,7]
15
# Example 3
root = [21,7,14,1,1,2,2,3,3]
9
Constraints
Related LeetCode Problems
Practice more problems similar to Binary Tree Tilt.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.