标签:null roo exp ber ack turn offer int 二叉树
题目来源:剑指offer
/* struct TreeNode { int val; struct TreeNode *left; struct TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) { } };*/ class Solution { public: vector<vector<int>> buffer; vector<int> tmp; vector<vector<int> > FindPath(TreeNode* root,int expectNumber) { if (root==NULL) return buffer; tmp.push_back(root->val); if(expectNumber==root->val && root->left==NULL && root->right==NULL) buffer.push_back(tmp); FindPath(root->left, expectNumber-root->val); FindPath(root->right, expectNumber-root->val); if(tmp.size()!=0) tmp.pop_back(); return buffer; } };
标签:null roo exp ber ack turn offer int 二叉树
原文地址:https://www.cnblogs.com/a-little-v/p/10927101.html