Tap here to switch tabs
Problem
Submissions

Problem: Sum of Nodes with Even-Valued Grandparent

Try to solve the Sum of Nodes with Even-Valued Grandparent problem.

Statement

Given the root of a binary tree, return the sum of the values of all nodes that have an even-valued grandparent. If no such nodes exist, return 00.

Note: A grandparent of a node is defined as the parent of its parent.

Constraints:

  • The number of nodes in the tree is in the range [1,104][1, 10^4].

  • 1≤1 \leq Node.val ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of Nodes with Even-Valued Grandparent

Try to solve the Sum of Nodes with Even-Valued Grandparent problem.

Statement

Given the root of a binary tree, return the sum of the values of all nodes that have an even-valued grandparent. If no such nodes exist, return 00.

Note: A grandparent of a node is defined as the parent of its parent.

Constraints:

  • The number of nodes in the tree is in the range [1,104][1, 10^4].

  • 1≤1 \leq Node.val ≤100\leq 100