1
2
3
4
5
6
7
8
9
10
|
class Solution:
def reverse(self, x: int) -> int:
x=str(x)
if x[0]=='-':
x=int(x[::-1][:-1])*-1
if x<=-1*pow(2,31): x=0
else:
x=int(x[::-1])
if x>=pow(2,31)-1 : x=0
return x
|
cs |
문제 자체는 안어려운데요
예외조건 Given~ 부분 잘 읽어보셔야됩니더
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode 1431. Kids With the Greatest Number of Candies (0) | 2021.07.13 |
---|---|
Leetcode 9. Palindrome Number (0) | 2021.07.12 |
Leetcode 1. Two Sum (0) | 2021.07.12 |
Leetcode 1672. Richest Customer Wealth (0) | 2021.07.12 |
Leetcode 1108. Defanging an IP Address (0) | 2021.07.12 |
댓글