标签:color describe .com blank 时间 搜索 深度 gre struct
/* 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> > paths; vector<int> tmp; vector<vector<int> > FindPath(TreeNode* root,int num) { if(root==NULL) return paths; tmp.push_back(root->val); if((num-root->val)==0 && root->left==NULL && root->right==NULL) { paths.push_back(tmp); } FindPath(root->left,num-root->val); FindPath(root->right,num-root->val); if(tmp.size()!=0) tmp.pop_back(); return paths; } };
标签:color describe .com blank 时间 搜索 深度 gre struct
原文地址:https://www.cnblogs.com/evidd/p/10623559.html