def isPalundrome(s):
strs=[]
for char in s:
if char.isalnum(): #영문자,숫자 여부를 판별하는 함수
strs.append(char.lower()) #대소문자 구분 안함
while len(str)>1: #홀수 고려해서 1
if strs.pop(0) != strs.pop(): #리스트의 pop은 인덱스를 지정할 수 있음
return False
return True
import collection
def isPalundrome(s):
strs=collection.deque()
for char in s:
if char.isalnum():
strs.append(char.lower())
while len(str)>1:
if strs.popleft() != strs.pop():
return False
return True
def isPalundrome(s):
s=s.lower()
s=re.sub('[^a-z0-9]','',s)
return s==s[::-1] #문자열 뒤집기
'Coding Test' 카테고리의 다른 글
[백준] 17608.막대기 (0) | 2022.07.07 |
---|---|
[Leetcode] 17. Letter Combinations of a Phone Number (0) | 2022.06.24 |
[Leetcode] 3. Longest Substring Without Repeating Characters (0) | 2022.05.21 |
[백준] 9012.괄호 (0) | 2022.04.05 |
[백준] 9935. 문자열 폭발 (0) | 2022.04.05 |