class Solution(object):
def isPalindrome(self, x: int) -> bool:
# positive만 가능
if x < 0:
return False
remains = list()
while True:
remains.append(x % 10)
x = x // 10
if x == 0:
break
if remains == list(reversed(remains)):
return True
else:
return False
반응형
'자료구조&알고리즘 > 알고리즘-문제풀이' 카테고리의 다른 글
[BAEKJOON] 2884-알람시계 (0) | 2021.06.30 |
---|---|
Leetcode-easy-13. Roman to Integer (0) | 2020.07.15 |
Leetcode-easy-7. Reverse Integer (0) | 2020.07.14 |
Leetcode-easy-1.Two Sum (0) | 2020.07.14 |
[프로그래머스-Level2] 프린터 (0) | 2020.06.24 |