Leetcode Palindrome Number problem solution in C++ programming

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,

By Neha Singhal

Hi, my name is Neha singhal a software engineer and coder by profession. I like to solve coding problems that give me the power to write posts for this site.

Leave a Reply

Your email address will not be published. Required fields are marked *