Palindrome Number - LeetCode
Can you solve this real interview question? Palindrome Number - Given an integer x, return true if x is a palindrome, and false otherwise. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Ex
leetcode.com
1
2
3
4
5
6
|
class Solution:
def isPalindrome(self, x: int) -> bool:
if str(x) == str(x)[::-1]:
return True
else:
return False
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 35. Search Insert Position (0) | 2023.06.26 |
---|---|
leetcode 172. Factorial Trailing Zeroes (0) | 2023.06.26 |
백준 1152 단어의 개수 (0) | 2023.06.24 |
백준 1157 단어 공부 (0) | 2023.06.24 |
leetcode 242. Valid Anagram (0) | 2023.06.23 |
댓글