From a1a1a87ad02be095278af328516da2075f873fe2 Mon Sep 17 00:00:00 2001 From: Vaibhavwani11 Date: Sat, 30 Oct 2021 12:13:25 +0530 Subject: [PATCH] Solved issue-Pallindrome Number --- 0011/Pallindrome.py | 12 ++++++++++++ 0011/Readme.md.txt | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 0011/Pallindrome.py create mode 100644 0011/Readme.md.txt diff --git a/0011/Pallindrome.py b/0011/Pallindrome.py new file mode 100644 index 0000000..892b49a --- /dev/null +++ b/0011/Pallindrome.py @@ -0,0 +1,12 @@ +class Solution: + def isPalindrome(self, x: int) -> bool: + temp = x + rev = 0 + while(x > 0): + dig = x % 10 + rev = rev * 10 + dig + x = x // 10 + if(temp == rev): + return True + else: + return False \ No newline at end of file diff --git a/0011/Readme.md.txt b/0011/Readme.md.txt new file mode 100644 index 0000000..af81004 --- /dev/null +++ b/0011/Readme.md.txt @@ -0,0 +1,39 @@ +# 9. Palindrome Number (easy) + +Given an integer x, return true if x is palindrome integer. + +An integer is a palindrome when it reads the same backward as forward. + +For example, 121 is palindrome while 123 is not. + +### Examples: + +Example 1: + + Input: x = 121 + Output: true + +Example 2: + + Input: x = -121 + Output: false + Explanation: From left to right, it reads -121. From right to left, it becomes 121-. + Therefore it is not a palindrome. + +Example 3: + + Input: x = 10 + Output: false + Explanation: Reads 01 from right to left. + Therefore it is not a palindrome. + +Example 4: + + Input: x = -101 + Output: false + +## Constraints: + + -231 <= x <= 231 - 1 + +#### Question link : [9_Palindrome_Number](https://leetcode.com/problems/palindrome-number/) \ No newline at end of file