Clean Java Solution


  • 0
    C
    '''
    public class Solution {
        public int reverse(int x) {
            String rev = rev + new StringBuilder(x + "").reverse().toString();
            if(rev.charAt(rev.length() - 1) == '-') rev = "-" + rev.substring(0,rev.length()-1);
            int r = 0;
            try
            {
                r = Integer.parseInt(rev);
            }
            catch(Exception e) {}
            return r;
        }
    }
    
    

Log in to reply
 

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