DEV Community

Oluwanifemi Latunde
Oluwanifemi Latunde

Posted on

Palindrome Number

Ooof! It's day 3 of the #I4G10DaysOfCodeChallenge and the question was to do a palindrome check on a number without first converting it into a string😪. Today's challenge was kind of tough for me, because I was familiar with first converting to a string to check for palindrome.

I was only able to solve the challenge with JavaScript this time.
I first did a check to eliminate negative numbers and numbers that ended with zero.
JavaScript Solution

Then I used some kind of logic to reverse the number as long as the number is greater than zero. And checked if the initial number was equal to the reversed number, or if it was equal to the reversed number divided by 10 for odd numbers.

I would love if someone could put me through the logic for python.
Below is the link to the challenge

https://leetcode.com/problems/palindrome-number/

Thank you❤️

Top comments (0)