Skip to content

Commit eba954e

Browse files
author
jinbeom
committed
Valid Palindrome Solution
1 parent a157c44 commit eba954e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

valid-palindrome/kayden.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 시간복잡도: O(N)
2+
# 공간복잡도: O(N)
3+
class Solution:
4+
5+
def isPalindrome(self, s: str) -> bool:
6+
string = ""
7+
8+
for letter in s:
9+
if letter.isalnum():
10+
string += letter.lower()
11+
12+
13+
def valid(s):
14+
st, en = 0, len(s)-1
15+
16+
while st < en:
17+
if s[st] != s[en]:
18+
return False
19+
20+
st += 1
21+
en -= 1
22+
23+
return True
24+
25+
return valid(string)

0 commit comments

Comments
 (0)