package com.sid.leetcode;

/**
 * 9. Palindrome Number.
 *
 * <blockquote>
 * Determine whether an integer is a palindrome. Do this without extra space.
 * </blockquote>
 *
 * @author Sid.Chen
 * @version 1.0, 2016-07-26
 *
 */
public class A0009_PalindromeNumber {

	public boolean isPalindrome(int x) {
		if (x < 0) return false;
		if (x < 10) return true;

		int multiple = 1;
		while (x / multiple >= 10) {
			multiple *= 10;
		}

		while(multiple > 1) {
			if (x / multiple != x % 10) return false;
			x %= multiple;
			x /= 10;
			multiple /= 100;
		}
		return true;
	}

}

@@ -116,16 +116,90 @@
 indrome.
+ An integer is a palindrome when it reads the same backward as forward.%0A *
  Do this
@@ -278,21 +278,21 @@
 n 1.
-0
+1
 , 201
-6-07-26
+9-06-30
 %0A *%0A
@@ -363,16 +363,22 @@
 indrome(
+final 
 int x) %7B
@@ -436,201 +436,158 @@
 ue;%0A
-%0A%09%09int multiple = 1;%0A%09%09while (x / multiple %3E
+        if (x %25 10 =
 = 
-1
 0) 
-%7B%0A%09%09%09multipl
+return false;%0A%09%09%0A%09%09int revers
 e 
-*
 = 
-10;%0A%09%09%7D%0A%0A%09%09while(multiple %3E 1) %7B%0A%09%09%09if (x / multipl
+0, temp = x;%0A%09%09while (temp %3E reverse) %7B%0A%09%09%09revers
 e 
-!
 = 
-x %25 10) return false;%0A%09%09%09x %25= multiple;%0A%09%09%09x /= 10;%0A%09%09%09multiple
+reverse * 10 + temp %25 10;%0A%09%09%09temp
  /= 10
-0
 ;%0A%09%09
@@ -597,20 +597,55 @@
 %09return 
-true
+reverse == temp %7C%7C reverse / 10 == temp
 ;%0A%09%7D%0A%0A%7D%0A

Add solution to #9 Palindrome Number