(root, string)
| 61 | return 0 |
| 62 | |
| 63 | def helper(root, string): |
| 64 | if not root.left and not root.right: |
| 65 | result.append(int(string+str(root.val))) |
| 66 | return |
| 67 | |
| 68 | if root.left: |
| 69 | helper(root.left, string+str(root.val)) |
| 70 | |
| 71 | if root.right: |
| 72 | helper(root.right, string+str(root.val)) |
| 73 | helper(root, '') |
| 74 | return sum(result) |