void sumNumbers(TreeNode *n, int num, int& sum) {
num = num*10 + n->val;
if (n->left == NULL & n->right == NULL) {
sum += num;
return;
}
if (n->left != NULL) {
sumNumbers(n->left, num, sum);
}
if (n->right != NULL){
sumNumbers(n->right, num, sum);
}
}
int sumNumbers(TreeNode *root) {
if (root == NULL) return 0;
int sum = 0;
sumNumbers(root, 0, sum);
return sum;
}