My 6-line acceptded java code


  • 0
    R
    public boolean isPalindrome(int x) {
            String s = x + "";
    		
    		int i = 0, j = s.length() - 1;
    		
    		while(i <= j + 1 && s.charAt(i++) == s.charAt(j--));
    		
    		if(i - j > 1) {
    			return true;
    		}
    		
    		return false;
        }
    

Log in to reply
 

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