@@ -0,0 +1,711 @@
+package leetcode.sum_root_to_leaf_numbers;%0A%0Aimport common.TreeNode;%0A%0Apublic class Solution %7B%0A%09int ans;%0A%09%0A%09public void dfs(TreeNode cur, int val)%7B%0A%09%09val = val * 10 + cur.val;%0A%09%09if(cur.left == null && cur.right == null)%7B%0A%09%09%09ans += val;%0A%09%09%7Delse%7B%0A%09%09%09if(cur.left != null)%7B%0A%09%09%09%09dfs(cur.left, val);%0A%09%09%09%7D%0A%09%09%09if(cur.right != null)%7B%0A%09%09%09%09dfs(cur.right, val);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%09%0A%09public int sumNumbers(TreeNode root) %7B%0A%09%09if(root == null) return 0;%0A%09%09ans = 0;%0A%09%09dfs(root, 0);%0A%09%09return ans;%0A%09%7D%0A%0A%09public static void main(String%5B%5D args)%7B%0A%09%09TreeNode root = new TreeNode(1);%0A%09%09root.left = new TreeNode(3);%0A%09%09root.right = new TreeNode(5);%0A%09%09root.left.left = new TreeNode(7);%0A%09%09System.err.println(new Solution().sumNumbers(root));%0A%09%7D%0A%7D%0A

Add java solution for 129. Sum Root to Leaf Numbers