In the Leetcode Palindrome Number problem solution in C programming Given an integer x, return true if x is a palindrome, and false otherwise.
Leetcode Palindrome Number problem solution in C programming
bool isPalindrome(int x){
int count = 0;
int* arr = (int*)malloc(sizeof(int)*15);
int i =0;
if(x >= 0)
{
while( x != 0)
{
arr[count] = x%10;
x = x/10;
count++;
}
for(i=0;i<count/2;i++)
{
if(arr[i] != arr[count-i-1])
{
return false;
}
}
}
else
{
return false;
}
return true;
}
Also read,
- Leetcode Palindrome Number problem solution in C++
- Leetcode Palindrome Number problem solution in Java
- Leetcode Palindrome Number problem solution in Python
- Leetcode Palindrome Number problem solution in C#