Sum of Nodes with Even-Valued Grandparent
Given a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it exists.)
If there are no nodes with an even-valued grandparent, return 0
.
Example 1:
Constraints:
The number of nodes in the tree is between
1
and10^4
.The value of nodes is between
1
and100
.
Last updated