package leetcode;

/**
 * https://leetcode.com/problems/leaf-similar-trees/
 */
public class Problem872 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

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

    public boolean leafSimilar(TreeNode root1, TreeNode root2) {
        // TODO
        return false;
    }

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

@@ -12,16 +12,68 @@
 tcode;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 /**%0A * h
@@ -392,36 +392,226 @@
     
-// TODO%0A        return false
+List%3CInteger%3E leaves1 = new ArrayList%3C%3E();%0A        collectLeafValues(root1, leaves1);%0A        List%3CInteger%3E leaves2 = new ArrayList%3C%3E();%0A        collectLeafValues(root2, leaves2);%0A        return leaves1.equals(leaves2)
 ;%0A  
@@ -616,29 +616,30 @@
     %7D%0A%0A    p
-ublic
+rivate
  static void
@@ -643,73 +643,339 @@
 oid 
-main(String%5B%5D args) %7B%0A        Problem872 prob = new Problem872();
+collectLeafValues(TreeNode root, List%3CInteger%3E leaves) %7B%0A        if (root == null) %7B%0A            return;%0A        %7D%0A        if (root.left == null && root.right == null) %7B%0A            leaves.add(root.val);%0A        %7D else %7B%0A            collectLeafValues(root.left, leaves);%0A            collectLeafValues(root.right, leaves);%0A        %7D
 %0A   

Solve problem 872