class Solution {public: void recur(TreeNode* root, const int expectNumber, int curr, vector >& res, vector & 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 > FindPath(TreeNode* root,int expectNumber) { vector > res; vector path; if(root == nullptr) return res; int curr = 0; recur(root, expectNumber, curr, res, path); return res; }};