Tap here to switch tabs
Problem
Submissions

Problem: Insufficient Nodes in Root to Leaf Paths

Try to solve the Insufficient Nodes in Root to Leaf Paths problem.

Statement

Given the root of a binary tree and an integer limit, delete all insufficient nodes from the tree and return the root of the resulting binary tree.

A node is considered insufficient if every root to leaf path passing through that node has a sum strictly less than limit.

A leaf is a node with no children.

Constraints:

  • The number of nodes in the tree is in the range [1,5000][1, 5000].

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5

  • −109≤-10^9 \leq limit ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Insufficient Nodes in Root to Leaf Paths

Try to solve the Insufficient Nodes in Root to Leaf Paths problem.

Statement

Given the root of a binary tree and an integer limit, delete all insufficient nodes from the tree and return the root of the resulting binary tree.

A node is considered insufficient if every root to leaf path passing through that node has a sum strictly less than limit.

A leaf is a node with no children.

Constraints:

  • The number of nodes in the tree is in the range [1,5000][1, 5000].

  • −105≤-10^5 \leq Node.val ≤105\leq 10^5

  • −109≤-10^9 \leq limit ≤109\leq 10^9