Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 462 Bytes

leetcode-9.md

File metadata and controls

24 lines (16 loc) · 462 Bytes

Solution

Link

class Solution {
    public boolean isPalindrome(int x) {
        
        if(x<0) return false;
        
        int reversedNum =0, remainder, original = x;
        
        while(x!=0){
            remainder = x %10;
            reversedNum = reversedNum * 10 + remainder;
            
            x /= 10;
        }
        
        return original == reversedNum;
    }
}