@@ -0,0 +1,1513 @@
+/**%0A * Definition for a binary tree node.%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        if(root == null)%7B%0A            return 0;%0A        %7D%0A        Stack%3CTreeNode%3E st = new Stack%3CTreeNode%3E();%0A        Stack%3CString%3E st2 = new Stack%3CString%3E();%0A        List%3CString%3E strs= new ArrayList%3CString%3E();%0A        String str = %22%22;%0A        %0A        st2.push(%22%22);%0A%0A        while(root != null)%7B%0A            st2.push(st2.peek() + root.val);%0A            st.push(root);%0A            root = root.left;%0A        %7D%0A        while(!st.empty())%7B%0A            TreeNode tmp = st.pop();%0A            str = st2.pop();%0A            if(tmp.left == null && tmp.right == null)%7B%0A                strs.add(str);%0A            %7D%0A            if(tmp.right == null)%7B%0A                continue;%0A            %7Delse%7B%0A                root = tmp.right;%0A                st.push(root);%0A                st2.push(str + root.val);%0A                while(root.left != null)%7B%0A                    root = root.left;%0A                    st.push(root);%0A                    st2.push(st2.peek() + root.val);%0A                %7D%0A                continue;%0A            %7D%0A        %7D%0A        double result = 0;%0A        for(String s: strs)%7B%0A            result += Integer.parseInt(s);%0A            if(result %3E Integer.MAX_VALUE)%7B%0A                return Integer.MAX_VALUE;%0A            %7D%0A        %7D%0A        return (int) result;%0A    %7D%0A%7D

Q129 Sum Root to Leaf Numbers