10 line JAVA code by converting to string


  • 0
    K

    public boolean isPalindrome(int x) {
    boolean status=true;
    String test=Integer.toString(x);
    for(int i=0;i<test.length()/2;i++)
    {
    if(test.charAt(i)!=test.charAt(test.length()-i-1))
    {status=false;
    break;}
    }
    return status;


Log in to reply
 

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