Problem Statement
You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number, formed by concatenating the node values from root to leaf (e.g., path 1 → 2 → 3 represents 123). A leaf is a node with no children. Return the total sum of all root-to-leaf numbers. Test cases are generated so the answer fits in a 32-bit integer.[5][9]
Example 1
Input: root =[1][2][3]
1 / \ 2 3
Output: 25
Explanation: Paths are 12 + 13 = 25.[9][1]
Example 2
Input: root =[4][1][5][9]
4 / \ 9 0 / \ 5 1
Output: 1026
Explanation: Paths are 495 + 491 + 40 = 1026.[9]
Example 3
Input: root =[1]
1 / \ 0 1 / \ / \ 0 1 0 1
Output: 22
Explanation: Paths include 100, 101, 110, 111, summing to 22.[9]
Constraints