package leetcode;

/**
 * https://leetcode.com/problems/sum-of-nodes-with-even-valued-grandparent/
 */
public class Problem1315 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    public int sumEvenGrandparent(TreeNode root) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1315 prob = new Problem1315();
    }
}

@@ -12,16 +12,68 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 /**%0A * h
@@ -402,15 +402,181 @@
     
-// TODO
+return sumEvenGrandparent(root, new ArrayList%3C%3E());%0A    %7D%0A%0A    private static int sumEvenGrandparent(TreeNode root, List%3CInteger%3E grandparents) %7B%0A        if (root == null) %7B
 %0A   
@@ -576,24 +576,28 @@
 ) %7B%0A        
+    
 return 0;%0A  
@@ -594,16 +594,493 @@
 turn 0;%0A
+        %7D%0A        int even = 0;%0A        if (grandparents.size() %3E= 2 && grandparents.get(grandparents.size() - 2) %25 2 == 0) %7B%0A            even = root.val;%0A        %7D%0A        List%3CInteger%3E copy = new ArrayList%3C%3E(grandparents);%0A        copy.add(root.val);%0A        int left = sumEvenGrandparent(root.left, copy);%0A        copy = new ArrayList%3C%3E(grandparents);%0A        copy.add(root.val);%0A        int right = sumEvenGrandparent(root.right, copy);%0A        return even + left + right;%0A
     %7D%0A%0A 

Update problem 1315