Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- gs25
- Baekjoon
- 데이콘
- 맥북
- dacon
- 파이썬
- ubuntu
- 자연어처리
- Git
- 백준
- hackerrank
- 캐치카페
- AI 경진대회
- github
- programmers
- 프로그래머스 파이썬
- PYTHON
- SW Expert Academy
- 편스토랑
- 금융문자분석경진대회
- 코로나19
- leetcode
- 프로그래머스
- Kaggle
- 더현대서울 맛집
- ChatGPT
- 편스토랑 우승상품
- Docker
- Real or Not? NLP with Disaster Tweets
- 우분투
Archives
- Today
- Total
솜씨좋은장씨
[leetCode] 9. Palindrome Number (Python) 본문
728x90
반응형
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
Example 1:
Input: 121
Output: true
Example 2:
Input: -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: 10
Output: false
Explanation: Reads 01 from right to left. Therefore it is not a palindrome.
Follow up:
Coud you solve it without converting the integer to a string?
Solution
class Solution:
def isPalindrome(self, x: int) -> bool:
x = list(str(x))
return x == x[::-1]
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[leetCode] 137. Single Number II (Python) (2) | 2020.07.20 |
---|---|
[leetCode] 383. Ransom Note (Python) (0) | 2020.07.19 |
[leetCode] 819. Most Common Word (Python) (0) | 2020.07.17 |
[leetCode] 372. Super Pow (Python) (0) | 2020.07.15 |
[leetCode] 371. Sum of Two Integers (Python) (0) | 2020.07.14 |
Comments