|
2 | 2 |
|
3 | 3 | importcom.fishercoder.common.classes.TreeNode;
|
4 | 4 |
|
5 |
| -/** |
6 |
| - * 1315. Sum of Nodes with Even-Valued Grandparent |
7 |
| - * |
8 |
| - * Given a binary tree, return the sum of values of nodes with even-valued grandparent. |
9 |
| - * (A grandparent of a node is the parent of its parent, if it exists.) |
10 |
| - * If there are no nodes with an even-valued grandparent, return 0. |
11 |
| - * |
12 |
| - * Example 1: |
13 |
| - * 6 |
14 |
| - * / \ |
15 |
| - * 7 8 |
16 |
| - * / \ / \ |
17 |
| - * 2 7 1 3 |
18 |
| - * / / \ \ |
19 |
| - * 9 1 4 5 |
20 |
| - * |
21 |
| - * Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] |
22 |
| - * Output: 18 |
23 |
| - * Explanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents. |
24 |
| - * |
25 |
| - * Constraints: |
26 |
| - * The number of nodes in the tree is between 1 and 10^4. |
27 |
| - * The value of nodes is between 1 and 100. |
28 |
| - * */ |
29 | 5 | publicclass_1315 {
|
30 | 6 | publicstaticclassSolution1 {
|
31 | 7 | publicintsumEvenGrandparent(TreeNoderoot) {
|
|