Why it's wrong answer,looks like integer overflow.


  • 0
    H

    i just according to the catalan Formula,and write the code to get the answer,but it's wrong,when the input is 19,it looks like a Integer overflow error,but i didn't know why the dp method dont have such an error?
    here is my code:

    
    calss Solution{
    public:
       int numTrees(int n){
        if(n==0) return 1;
        else return numtrees(n-1)**(4**n-2)/(n+1);
      }
    };
    

Log in to reply
 

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