solution not working for input 1


  • 0
    P

    My code is not working for input 1, its giving false, any suggestions??

    public class Solution {
    public boolean isPalindrome(int x) {
    long result = 0;
    while(x!=0)
    {
    int mod = x%10;
    x = x/10;
    result = result*10+mod;

        }
        System.out.println(result);
        if(x==(int)result)
        {
            return true;
        }
         else
        {
            return false;
        }
    }
    

    }


Log in to reply
 

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