Home > Back-end >  LeetCode 9 palindrome
LeetCode 9 palindrome

Time:09-24

Bool isPalindrome (int x;
{
If (x & lt; 0 | | x>
=2147483647){return false;
} else {
Int r
Esult=0;
Int s=0;
Int temp=x;
While (x!=0)
{s=x % 10;
Result=result * 10 + s; X=x/10;
}
If ((temp==result | | temp==0))
{return true; }
The else {return false. }
}}
First why if x is equal to its range, is not the same as that is the value will lead to the result overflow spill, strives for the light,
Of course is defined as a long int type will not overflow,
  • Related