https://leetcode.com/problems/sum-root-to-leaf-numbers



Runtime: 2 ms, faster than 14.23% of Java online submissions for Sum Root to Leaf Numbers.
Memory Usage: 36.5 MB, less than 50.37% of Java online submissions for Sum Root to Leaf Numbers.



```java
class Solution {
    private int result;
    private void travel(List<String> sum_list, TreeNode node) {
        if (node == null) {

        } else {
            sum_list.add(String.valueOf(node.val));
            if (node.left != null) {
                travel(sum_list, node.left);
            }
            if (node.right != null) {
                travel(sum_list, node.right);
            }
            if (node.left == null && node.right == null) {
                String sum = "";
                for (String each : sum_list) {
                    sum += each;
                }
                result += Integer.parseInt(sum);
            }
        }
    }

    public int sumNumbers(TreeNode root) {
        //8:15
        result = 0;
        List<String> hi = new ArrayList<String>();
        travel(hi, root);
        return result;
        //8:22
    }
}
```
