Strings

Algorithm/Python

[LeetCode - Top Interview Questions(Easy, Python3)]Strings

1. Reverse String class Solution: def reverseString(self, s: List[str]) -> None: """ Do not return anything, modify s in-place instead. """ s.reverse() in-place라 reverse()를 사용했지만, slicing(s[:] = s[::-1])이 조금 더 빠르다. 2. Reverse Integer class Solution: def reverse(self, x: int) -> int: if x == 0: return 0 result = int(str(abs(x))[::-1]) # 32-bit 정수 범위를 넘은 경우 0으로 처리 if result2**31-1: return 0 # x가 양..

박한결
'Strings' 태그의 글 목록