Accepted Solution


  • 0
    A
    public class Solution {
        public boolean isPalindrome(int x) {
            int y = x;
            int rev = 0;
            boolean flag = false;
            if (x < 0){
                flag = true;
            }
            while (y != 0){
                rev = rev * 10 + y % 10;
                y /= 10;
            }
            if (rev == x){
                if(flag){
                    return false;
                }
                return true;
            }
            return false;
        }
    }

Log in to reply
 

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