Leetcode 563. Binary Tree Tilt
Compute the sum of every node's tilt in a binary tree, where a node's tilt is the absolute difference between the sum of values in its left and right subtrees. This is solved by a post-order traversal that returns subtree sums and accumulates each node's absolute difference (one-pass O(n) solution).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid August, 2026
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.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.