1530. Number of Good Leaf Nodes Pairs
Last updated
Last updated
https://leetcode.com/problems/number-of-good-leaf-nodes-pairs
Given the root
of a binary tree and an integer distance
. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance
.
Return the number of good leaf node pairs in the tree.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
The number of nodes in the tree
is in the range [1, 2^10].
Each node's value is between [1, 100]
.
1 <= distance <= 10