Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 672 Bytes

File metadata and controls

24 lines (21 loc) · 672 Bytes
void help(Node *root,int s,int sum,vector<int>temp,vector<vector<int>>&ans){
        if(!root)
        return;
        s+=root->key;
        temp.push_back(root->key);
        if(s==sum)
        ans.push_back(temp);
        help(root->left,s,sum,temp,ans);
        help(root->right,s,sum,temp,ans);
    }
    vector<vector<int>> printPaths(Node *root, int sum)
    {
        //code here
        vector<vector<int>>ans;
        vector<int>temp;
        help(root,0,sum,temp,ans);
        return ans;
    }