Zero to Hero
article thumbnail
Published 2021. 4. 17. 21:44
7. Reverse Integer Algorithm
 

Reverse Integer - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

1. 내 풀이

class Solution:
    def reverse(self, x: int) -> int:
        x = int(str(x)[::-1]) if str(x)[-1] != "-" else int("-" + str(x)[::-1][:-1])
        return x if abs(x) < 2 ** 31 else 0
        

'Algorithm' 카테고리의 다른 글

424. Longest Repeating Character Replacement  (0) 2021.04.19
2174번: 로봇 시뮬레이션  (0) 2021.04.18
104. Maximum Depth of Binary Tree  (0) 2021.04.16
13549번: 숨바꼭질 3  (0) 2021.04.15
283. Move Zeroes  (0) 2021.04.15
profile

Zero to Hero

@Doljae

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!