# A solution without any extra space but 10 if/else and 87 lines!!!

• ``````bool isPalindrome(int x)
{
if(x < 0)
return false;
if(x / 1000000000 == 0)
{
if(x / 100000000 == 0)
{
if(x / 10000000 == 0)
{
if(x / 1000000 == 0)
{
if(x / 100000 == 0)
{
if(x / 10000 == 0)
{
if(x / 1000 == 0)
{
if(x / 100 == 0)
{
if(x / 10 == 0)
{
return true;
}
else
{
return x / 10 % 10 == x % 10;
}
}
else
{
return x / 100 % 10 == x % 10;
}

}
else
{
return x / 1000 % 10 == x % 10
&& x / 100 % 10 == x / 10 % 10;
}
}
else
{
return x / 10000 % 10 == x % 10
&& x / 1000 % 10 == x / 10 % 10;
}
}
else
{
return x / 100000 % 10 == x % 10
&& x / 10000 % 10 == x / 10 % 10
&& x / 1000 % 10 == x / 100 % 10;
}
}
else
{
return x / 1000000 % 10 == x % 10
&& x / 100000 % 10 == x / 10 % 10
&& x / 10000 % 10 == x / 100 % 10;
}
}
else
{
return x / 10000000 % 10 == x % 10
&& x / 1000000 % 10 == x / 10 % 10
&& x / 100000 % 10 == x / 100 % 10
&& x / 10000 % 10 == x / 1000 % 10;
}
}
else
{
return x / 100000000 % 10 == x % 10
&& x / 10000000 % 10 == x / 10 % 10
&& x / 1000000 % 10 == x / 100 % 10
&& x / 100000 % 10 == x / 1000 % 10;
}

}
else
{
return x / 1000000000 % 10 == x % 10
&& x / 100000000 % 10 == x / 10 % 10
&& x / 10000000 % 10 == x / 100 % 10
&& x / 1000000 % 10 == x / 1000 % 10
&& x / 100000 % 10 == x / 10000 % 10;
}
}
``````

• That's huge! Hahaha! Solve the problem without use variable. But you know this will also consume EXTRA CPU register memory. No one can solve problems without extra space.

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