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


Runtime: 4 ms, faster than 51.78% of C++ online submissions for Sum Root to Leaf Numbers.
Memory Usage: 12.1 MB, less than 5.17% of C++ online submissions for Sum Root to Leaf Numbers.



```cpp
class Solution {
public:
    long result;

    void travel(vector<string> sum_list, TreeNode* node) {
      if (node == nullptr) {

      } else {
        sum_list.push_back(to_string(node->val));
        if (node->left != nullptr) {
          travel(sum_list, node->left);
        }
        if (node->right != nullptr) {
          travel(sum_list, node->right);
        }
        if (node->right == nullptr && node->left == nullptr) {
          string sum = "";
          for (string each : sum_list) {
            sum += each;
          }
          result += stol(sum);
        }
      }
    }

    int sumNumbers(TreeNode* root) {
      //8:06
      result = 0;
      vector<string> hi;
      travel(hi, root);
      return result;
      //8:12
    }
};
```
