@@ -0,0 +1,1137 @@
+/***%0A * Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.%0A *%0A * An example is the root-to-leaf path 1-%3E2-%3E3 which represents the number 123.%0A *%0A * Find the total sum of all root-to-leaf numbers.%0A *%0A * For example,%0A *%0A *     1%0A *    / %5C%0A *   2   3%0A * The root-to-leaf path 1-%3E2 represents the number 12.%0A * The root-to-leaf path 1-%3E3 represents the number 13.%0A *%0A * Return the sum = 12 + 13 = 25.%0A */%0A/**%0A * Definition for binary tree%0A * public class TreeNode %7B%0A *     int val;%0A *     TreeNode left;%0A *     TreeNode right;%0A *     TreeNode(int x) %7B val = x; %7D%0A * %7D%0A */%0Apublic class Solution %7B%0A    public int sumNumbers(TreeNode root) %7B%0A        int sum%5B%5D = new int sum%5B1%5D;%0A        int path = 0;%0A        dfs(sum, root, path);%0A        return sum%5B0%5D;%0A    %7D%0A    private void dfs(int%5B%5D sum, TreeNode root, int path) %7B%0A        if (root == null)%0A            return;%0A        path = path * 10 + root.val;%0A        if (root.left == null && root.right == null) %7B%0A            sum%5B0%5D += path;%0A            return;%0A        %7D%0A        dfs(sum, root.left, path);%0A        dfs(sum, root.right, path);%0A    %7D%0A%7D%0A

add SumRoottoLeafNumbers.java