标签:vector push null oid cto int node == off
/* 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> > FindPath(TreeNode* root,int expectNumber) { vector<vector<int> >res; vector<int> cur; path(root,expectNumber,res,cur); return res; } void path(TreeNode *root,int sum, vector<vector<int> >&res,vector<int> &cur) { if(root==NULL) return ; cur.push_back(root->val); if(root->left==NULL&&root->right==NULL) { if(sum==root->val) res.push_back(cur); } if(root->left) path(root->left,sum-root->val,res,cur); if(root->right) path(root->right,sum-root->val,res,cur); cur.pop_back(); } };
标签:vector push null oid cto int node == off
原文地址:http://www.cnblogs.com/159269lzm/p/7296366.html