Skip to content

Commit 8918c97

Browse files
committed
Valid Palindrome
1 parent 7555cad commit 8918c97

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

valid-palindrome/thispath98.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
# Time Complexity: O(N)
3+
- N개의 char를 각각 한번씩 순회
4+
# Space Compelexity: O(N)
5+
- 최악의 경우 (공백이 없을 경우) N개의 char 저장
6+
"""
7+
class Solution:
8+
def isPalindrome(self, s: str) -> bool:
9+
string = [char.lower() for char in s if char.isalnum()]
10+
for i in range(len(string) // 2):
11+
if string[i] != string[-i - 1]:
12+
return False
13+
return True

0 commit comments

Comments
 (0)