calculateTiltAndSum(node)
that returns a tuple containing the tilt of the current node and the sum of values in the subtree rooted at the current node.null
, return (0, 0) as the tilt and sum.calculateTiltAndSum(node.left)
to get the left tilt and left sum.calculateTiltAndSum(node.right)
to get the right tilt and right sum.calculateTiltAndSum(root)
and return the total tilt.