Sum root to leaf paths


  • 0
    T

    Hi my code is not compling it is giving error that :expected primary-expression before '*' token ,This error occurs when i try to call my explicit function sum

    class Solution {
    public:
    int sum(struct TreeNode * root,int value)
    {
    if(root==NULL)
    return 0;

        int m=root->val;
        value=value*10+m;
        if(root->left==NULL && root->right==NULL)
        {
            return value;
        }
        
        
        return sum(root->left,value)+sum(root->right,value);
        
    }
    int sumNumbers(TreeNode *root) {
        
        int sum1=sum(TreeNode *root,0);
        
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.