Sum of Right Leaves
Given a binary tree root
, return the sum of all leaves that are right children.
Constraints
n ≤ 100,000
wheren
is the number of nodes inroot
https://binarysearch.com/problems/Sum-of-Right-Leaves
Examples
Example 1
Input
- root =
Output
- answer =
2
Example 2
Input
- root =
Output
- answer =
10
Explanation
Since 7 + 3 = 10
.
Leave a comment