Skip to content

Commit

Permalink
Time: 3 ms (40.21%), Space: 8.2 MB (42.98%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
gogumaC committed Jan 2, 2025
1 parent 0c97cfb commit e4066c7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 0009-palindrome-number/0009-palindrome-number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
bool isPalindrome(int x) {

int len = 0;
int xx = x;
do
{
xx/=10;
len++;
}while(xx);

if(x<0)
{
len++;
}

char str[len+1];
sprintf(str,"%d",x);

for(int i=0; i<=len/2; i++)
{
if(str[i]!=str[len-i-1])
{
return false;
}
}

return true;

}

0 comments on commit e4066c7

Please sign in to comment.