Best solution


  • 0
    M

    Re: Solution in Java.
    public int reverse(int x) {
    try {
    return x > 0 ? Integer.parseInt(new StringBuffer("" + x).reverse().toString()) : -Integer.parseInt(new StringBuffer("" + -x).reverse().toString());
    } catch (NumberFormatException ex)
    {
    return 0;
    }
    }


Log in to reply
 

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