Binary Tree Tilt
Easy · Trees · about 10 minutes
Asked at Google, Amazon, Meta.
For any node, its tilt is how far apart the total of its left subtree and the total of its right subtree are (as an absolute value; a missing subtree totals 0). Add up the tilts of all nodes.