# Real "without extra space" code, but ugly

• Because the max number of scenarios could be enumerated, I hard code it.

``````public class Solution {
public boolean isPalindrome(int x) {
if( x <= 9 && x >= 0) return true;
if( x < 0 ) return false;
if(0 != x / 1000000000){
if(x / 1000000000 != x % 10) return false;
else {x = x % 1000000000; x = x / 10;}
if(x / 10000000 != x % 10) return false;
else {x = x % 10000000; x = x / 10;}
if(x / 100000 != x % 10) return false;
else {x = x % 100000; x = x / 10;}
if(x / 1000 != x % 10) return false;
else {x = x % 1000; x = x / 10;}
if(x / 10 != x % 10) return false;
else return true;
}
if(0 != x / 100000000){
if(x / 100000000 != x % 10) return false;
else {x = x % 100000000; x = x / 10;}
if(x / 1000000 != x % 10) return false;
else {x = x % 1000000; x = x / 10;}
if(x / 10000 != x % 10) return false;
else {x = x % 10000; x = x / 10;}
if(x / 100 != x % 10) return false;
else {return true;}
}
if(0 != x / 10000000){
if(x / 10000000 != x % 10) return false;
else {x = x % 10000000; x = x / 10;}
if(x / 100000 != x % 10) return false;
else {x = x % 100000; x = x / 10;}
if(x / 1000 != x % 10) return false;
else {x = x % 1000; x = x / 10;}
if(x / 10 != x % 10) return false;
else return true;
}
if(0 != x / 1000000){
if(x / 1000000 != x % 10) return false;
else {x = x % 1000000; x = x / 10;}
if(x / 10000 != x % 10) return false;
else {x = x % 10000; x = x / 10;}
if(x / 100 != x % 10) return false;
else {return true;}
}
if(0 != x / 100000){
if(x / 100000 != x % 10) return false;
else {x = x % 100000; x = x / 10;}
if(x / 1000 != x % 10) return false;
else {x = x % 1000; x = x / 10;}
if(x / 10 != x % 10) return false;
else return true;
}
if(0 != x / 10000){
if(x / 10000 != x % 10) return false;
else {x = x % 10000; x = x / 10;}
if(x / 100 != x % 10) return false;
else {return true;}
}
if(0 != x / 1000){
if(x / 1000 != x % 10) return false;
else {x = x % 1000; x = x / 10;}
if(x / 10 != x % 10) return false;
else return true;
}
if(0 != x / 100){
if(x / 100 != x % 10) return false;
else {return true;}
}
if(0 != x / 10){
if(x / 10 != x % 10) return false;
else return true;
}
return false;
}
}
``````

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