P18183 [GeeksforGeeks] Sum of right leaf nodes
普及-
题目描述

Given a Binary Tree of size N, your task is to complete the function rightLeafSum(), which should return the sum of all the leaf nodes that are the right child of their parent of the given binary tree.
Example 1:
Input :
52
/ \
12 55
/ \ / \
83 6 17 82
/ / \
56 61 35
Output :
117
Explanation:
All the right leaf nodes
presents are 35, 82 which
sums up to 117
Example 2:
Input:
12
/ \
20 30
/ \ /
40 60 90
Output:
60
Explanation:
The only right leaf node is present is 60
Constraints:
1<=T<=100
1<=N<=100
Your task :
You don't have to read input or print anything. Your task is to complete the function rightLeafSum() that takes the root of the tree as input and return the sum of all
the right leaf node of the input tree.

输入格式

见题面

输出格式

见题面

样例输入
52 / \ 12 55 / \ / \ 83 6 17 82 / / \ 56 61 35
样例输出
117