Accepted Solution


#1

`void Sum(TreeNode* a, int b,vectorv, vector<vector>&ans){
if(a==NULL )
return ;
if(b-(a->val)==0 && a->left==NULL && a->right==NULL){
v.push_back(a->val);
ans.push_back(v);
return ;
}
v.push_back(a->val);
Sum(a->left,b-(a->val),v,ans);
free(a->left);
Sum(a->right,b-(a->val),v,ans);
free(a->right);

}

vector<vector > Solution::pathSum(TreeNode* a, int b) {
vector v;
vector<vector> Ans;
Sum(a,b,v,Ans);
free(a);
return Ans;
}`