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
class Solution {
public:
bool isPalindrome(int x) {
if(x<0)
return false;
long newNum = 0;
long temp = x;
long num = x;
while(num>0) {
newNum = newNum*10+num%10;
num/=10;
}
return newNum == temp;
}
};
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#