Determine whether an integer is a palindrome. Do this without extra space.
这道题其实挺没意思的,不能用extra space。没想到怎么不用extra space,希望有大神指出
public class Solution { public boolean isPalindrome(int x) { if(x<0) return false; String s = Integer.toString(x); int j=s.length() -1; int i = 0; while(i<j){ if(s.charAt(i) !=s.charAt(j)) return false; i++; j--; } return true; } }