Tap here to switch tabs
Problem
Submissions

Problem: Number of Good Leaf Nodes Pairs

Try to solve the Number of Good Leaf Nodes Pairs problem.

Statement

Given the root of a binary tree and an integer distance, return the total number of good leaf node pairs in the tree.

A pair of distinct leaf nodes is considered good if the length of the shortest path connecting them is less than or equal to distance.

Constraints:

  • The number of nodes in the tree is in the range [1,210][1, 2^{10}].

  • 1≤1 \leq Node.val ≤100\leq 100

  • 1≤1 \leq distance ≤10\leq 10

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Good Leaf Nodes Pairs

Try to solve the Number of Good Leaf Nodes Pairs problem.

Statement

Given the root of a binary tree and an integer distance, return the total number of good leaf node pairs in the tree.

A pair of distinct leaf nodes is considered good if the length of the shortest path connecting them is less than or equal to distance.

Constraints:

  • The number of nodes in the tree is in the range [1,210][1, 2^{10}].

  • 1≤1 \leq Node.val ≤100\leq 100

  • 1≤1 \leq distance ≤10\leq 10