Simple Logic And Try to Use this in Different Problems


#1
 int me(TreeNode *A,int val)
 {
    if(A==NULL)
    return 0;
    val=(val*10+A->val)%1003;
    if(A->left==NULL && A->right==NULL )
    {
        return (val)%1003;
    }
    else
    {
        return (me(A->left,val)%1003+me(A->right,val)%1003)%1003;
    }
}
int Solution::sumNumbers(TreeNode* A) {
    return me(A,0)%1003;
}