package javaProbs;
/**
 * LeetCode - Problem 9
 * 
 * Determine whether an integer is a palindrome. Do this without extra space.
 * 
 * @author DJTai
 *
 */
public class Solution_009_Palindrome
{

	public static void main(String[] args)
	{
		int num1 = 10109;
		int num2 = 10101;
		int num3 = 123454321;

		
		System.out.println(isPalindrome(num1));
		System.out.println(isPalindrome(num2));
		System.out.println(isPalindrome(num3));
	} // end main
	
	//-----Solution-----//
	public static boolean isPalindrome(int x)
	{
        int revX = x;
        int y = 0;
        
        while (revX > 0)
        {
            y = y * 10 + revX % 10;
            revX /= 10;
        }
        
        return y == x;
    } // end isPalindrome

} // end class
