class Solution {
public:
void recur(TreeNode* root, const int expectNumber, int curr, vector<vector<int>>& res, vector<int>& path){
path.push_back(root->val);
curr += root->val;
bool isLeaf = (root->left == nullptr && root->right == nullptr);
if(isLeaf && curr == expectNumber){
res.push_back(path);
}
if(root->left != nullptr){
recur(root->left, expectNumber, curr, res, path);
}
if(root->right != nullptr){
recur(root->right, expectNumber, curr, res, path);
}
path.pop_back();
}
vector<vector<int> > FindPath(TreeNode* root,int expectNumber) {
vector<vector<int>> res;
vector<int> path;
if(root == nullptr) return res;
int curr = 0;
recur(root, expectNumber, curr, res, path);
return res;
}
};