O(N) Java Solution


  • 0

    public class Solution {
    public boolean isPalindrome(int x) {
    String tmp = String.valueOf(x);
    int len = tmp.length()-1;
    int i=0;
    while(i<len){
    if(tmp.charAt(i)!=tmp.charAt(len)) return false;
    else{
    i++;
    len--;
    }
    }
    return true;
    }
    }


Log in to reply
 

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