Class Solution
java.lang.Object
g1301_1400.s1315_sum_of_nodes_with_even_valued_grandparent.Solution
1315 - Sum of Nodes with Even-Valued Grandparent.<p>Medium</p>
<p>Given the <code>root</code> of a binary tree, return <em>the sum of values of nodes with an <strong>even-valued grandparent</strong></em>. If there are no nodes with an <strong>even-valued grandparent</strong> , return <code>0</code>.</p>
<p>A <strong>grandparent</strong> of a node is the parent of its parent if it exists.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/08/10/even1-tree.jpg" alt="" /></p>
<p><strong>Input:</strong> root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]</p>
<p><strong>Output:</strong> 18</p>
<p><strong>Explanation:</strong> The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/08/10/even2-tree.jpg" alt="" /></p>
<p><strong>Input:</strong> root = [1]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Constraints:</strong></p>
<ul>
<li>The number of nodes in the tree is in the range <code>[1, 10<sup>4</sup>]</code>.</li>
<li><code>1 <= Node.val <= 100</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
sumEvenGrandparent
-