일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Python
- concurrency
- attribute
- Decorator
- 시바견
- 운영체제
- 109. Convert Sorted List to Binary Search Tree
- t1
- 컴퓨터의 구조
- Protocol
- Regular Expression
- Python Code
- Class
- 파이썬
- 715. Range Module
- 밴픽
- 프로그래머스
- iterator
- Generator
- kaggle
- LeetCode
- 30. Substring with Concatenation of All Words
- 315. Count of Smaller Numbers After Self
- Python Implementation
- shiba
- Convert Sorted List to Binary Search Tree
- data science
- Substring with Concatenation of All Words
- DWG
- 43. Multiply Strings
Archives
- Today
- Total
Scribbling
LeetCode: 125. Valid Palindrome 본문
class Solution:
def isPalindrome(self, s: str) -> bool:
s = s.lower().strip()
if not s:
return True
l, r = 0, len(s) - 1
while l < r:
if not s[l].isalnum():
l += 1
continue
if not s[r].isalnum():
r -= 1
continue
if s[l] != s[r]:
return False
l += 1
r -= 1
return True
'Computer Science > Coding Test' 카테고리의 다른 글
LeetCode: 191. Number of 1 Bits (0) | 2021.12.21 |
---|---|
LeetCode: 171. Excel Sheet Column Number (0) | 2021.12.20 |
LeetCode: 101. Symmetric Tree (0) | 2021.12.19 |
LeetCode: 236. Lowest Common Ancestor of a Binary Tree (0) | 2021.12.15 |
LeetCode: 230. Kth Smallest Element in a BST (0) | 2021.12.14 |