Leetcode 9: Palindrome Number

Category : Easy

Problem

Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.

Follow up: Could you solve it without converting the integer to a string?

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

Examples

Example 1:

Example 2:

Example 3:

Example 4:

Constraints

  • -231 <= x <= 231 - 1

Solution Approach

To check if the number is palindrome or not we just reverse the number by taking out the last digit from the number one by one and concatenating those digits to a new reverse number. In the end, we will compare those two numbers (original and the concatenated reverse number) and if they are equal then we can say that the number is palindrome otherwise they are not.

Solution code

For more Leetcode explained solutions visit Leetcode Solutions. If you like capture the flag challenges visit here.

Check out my socials below in the footer. Feel free to ask any doubts in the comment section or contact me via Contact page I will surely respond. Happy Leetcoding 

2 thoughts on “Leetcode 9: Palindrome Number”

  1. Pingback: Leetcode 1295: Find Numbers with Even Number of Digits - Cse Nerd

  2. Pingback: Leetcode 728: Self Dividing Numbers - Leetcode Detailed Solutions

Leave a Comment

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