Skip to content

Latest commit

 

History

History
18 lines (10 loc) · 570 Bytes

README.md

File metadata and controls

18 lines (10 loc) · 570 Bytes

181.Binary Tree Tilt

Description

Given a binary tree, return the tilt of the whole tree.

The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree node values. Null node has tilt 0.

The tilt of the whole tree is defined as the sum of all nodes' tilt.

Note

  • The sum of node values in any subtree won't exceed the range of 32-bit integer.
  • All the tilt values won't exceed the range of 32-bit integer.

From

LeetCode