728x90
using Slicing
leetcode-125
+ ์ ๊ท์ ์ฌ์ฉ
import re
import collections
class Solution:
def isPalindrome(self, s: str) -> bool:
s = s.lower()
s = re.sub('[^a-z0-9]','',s)
return s == s[::-1] # reverse
Result : 46ms Memory: 15.7mb
๋ฐ์ํ
'๐ข One step' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
LeetCode - Time complexity ์๊ฐ ๋ณต์ก๋ (0) | 2023.03.02 |
---|---|
[leetcode-819] Most Common Word (0) | 2023.03.02 |
[leetcode-937] Reorder_Data_in_LogFile (0) | 2023.03.01 |
[leetcode-344] ReverseString (0) | 2023.02.27 |
[leetcode-125] Palindrome (0) | 2023.02.26 |