Insufficient Nodes in Root to Leaf Paths
Given the root
of a binary tree, consider all root to leaf paths: paths from the root to any leaf. (A leaf is a node with no children.)
A node
is insufficient if every such root to leaf path intersecting this node
has sum strictly less than limit
.
Delete all insufficient nodes simultaneously, and return the root of the resulting binary tree.
Example 1:
Example 2:
Example 3:
Note:
The given tree will have between
1
and5000
nodes.-10^5 <= node.val <= 10^5
-10^9 <= limit <= 10^9
Last updated