Skip to content

Commit

Permalink
Added pallindrome number
Browse files Browse the repository at this point in the history
  • Loading branch information
puneeter committed Dec 29, 2024
1 parent e141dd7 commit 171d0b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions LeetCode/PalindromeNumber.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution(object):
def isPalindrome(self, x):
"""
:type x: int
:rtype: bool
"""
reversed_number = 0
copy_x = x
while x > 0:
last_digit = x % 10
reversed_number = reversed_number * 10 + last_digit
x = x // 10
return copy_x == reversed_number
1 change: 1 addition & 0 deletions LeetCode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
| [Merge Sort](MergeSort.py) | :heavy_check_mark: | `#recursion` `#sorting` | Python |
| [Merge Two Sorted Lists](MergeTwoSortedLists.py) | :heavy_check_mark: | `#recursion` `#linked-list` | Python |
| [N Queens II](NQueens2.py) | :heavy_check_mark: | `#recursion` `#backtracking` | Python |
| [Palindrome Number](PalindromeNumber.py) | :heavy_check_mark: | `#math` | Python |
| [Palindromic Substrings](PalindromicSubstrings.py) | :rocket: | `#recursion` `#dynamic-programming` `#memoization` | Python |
| [Pascal's Triangle II](PascalsTriangle2.py) | :heavy_check_mark: | `#recursion` | Python |
| [Pow(x,n)](Pow(x,n).py) | :heavy_check_mark: | `#recursion` `#memoization` | Python |
Expand Down

0 comments on commit 171d0b1

Please sign in to comment.