C++ easy cleanest code ever


#1
    void f(TreeNode* A,int B,vector<vector<int>>& ans,vector<int>& tmp){
        if(A==NULL)return;
        tmp.push_back(A->val);
        if(A->left==NULL and A->right==NULL and A->val==B)ans.push_back(tmp);
        if(A->left!=NULL)f(A->left,B-A->val,ans,tmp);
        if(A->right!=NULL)f(A->right,B-A->val,ans,tmp);
        tmp.pop_back();
    }
    vector<vector<int> > Solution::pathSum(TreeNode* A, int B) {
        vector<vector<int>>ans;vector<int>tmp;
        f(A,B,ans,tmp);
        return ans;
    }