My accepted Java solution


  • -2
    B

    public class Solution {

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

    }


  • 0
    T

    Actually I wonder what does 'no extra space' mean...


Log in to reply
 

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