# Copy of 129. Sum Root to Leaf Numbers

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

trick point:&#x20;

```java
int currentSum = sum*10 + root.val;
```

```java
class Solution {
    public int sumNumbers(TreeNode root) {
        return cal(root, 0);
    }
    private int cal(TreeNode root, int sum) {
        if (root == null) {
            return 0;
        }
        int currentSum = sum*10 + root.val;
        if (root.left == null && root.right == null) {
            return currentSum;
        }
        return cal(root.left, currentSum) + cal(root.right, currentSum);
        
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://timmybeeflin.gitbook.io/cracking-leetcode/dfs-and-bfs/dfs/129.-sum-root-to-leaf-numbers-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
