标签:
int sumNumbers(TreeNode *root) { return dfs(root, 0); } int dfs(TreeNode *root, int sum) { if (root == nullptr)return 0; if (root->left == nullptr && root->right == nullptr) return sum * 10 + root->val; return dfs(root->left, sum * 10 + root->val) + dfs(root->right, sum * 10 + root->val); }
标签:
原文地址:http://www.cnblogs.com/573177885qq/p/5656524.html