What is the problem of my anwser?


  • 0
    C
    int reverse(int x) 
    {
    int i,s = 0;
    for(i = 0; x =!0 ; i++)
    {   if (s > INT_MAX/10 || s < -INT_MAX/10)
                return 0;
        s = (s*10)+(x%10);
        x =x/10;   
    }
    if (x < 0)
        s = -s;
    return s/10;
    
    }
    

    could anybody tell me what is wrong in my code? for the input 1, the output is 0 (which should be 1), and only 6 of 1234 have passed


  • 0
    H

    This problem is broken. see mine:

    Input: 1534236469
    Output: 9646324351
    Expected: 0


  • 0
    L

    first: for(i=0;x!=0;i++)
    second: " return s/10; " must be return s;


Log in to reply
 

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