What's the Compiler is leetcode used?


  • 0
    R

    The Algorithms "isNumberHappy".
    The same program,when I run it in VS2010 or CodeBlocks,I get the right answer.
    But in leetcode,it haven't been accepted.The reason is the difference between the Compiles?I don't know.
    Here's the code.Help,please.

      bool isHappy(int n) {
            static map<int,bool> table;
            if(table.find(n)==table.end())
            table[n]=true;
            else
            return false;
            
            int sum=0;
            do
            {
                int m=n%10;
                n=n/10;
                sum=sum+m*m;
            }
            while(0!=n);
            
            if(1==sum)
            return true;
            else
            return isHappy(sum);
        }

Log in to reply
 

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