java


  • 0
    L

    class Solution {
    public int reverse(int x) {
    int flag=x>0?1:-1;
    long reverse=0;
    x=Math.abs(x);
    while(x>0){
    reverse=reverse10+x%10;
    x/=10;
    }
    if(reverse>Integer.MAX_VALUE){
    return 0;
    }else{
    return (int) (flag
    reverse);
    }

    }
    

    }


Log in to reply
 

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