We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 637ca7d commit f295e2fCopy full SHA for f295e2f
valid-palindrome/ohkingtaek.py
@@ -0,0 +1,17 @@
1
+class Solution:
2
+ def isPalindrome(self, s: str) -> bool:
3
+ """
4
+ - 시간복잡도: O(n)
5
+ - 공간복잡도: O(n)
6
+ 1. 문자열을 소문자로 변환하고, 알파벳과 숫자만 남기기
7
+ 2. 남은 문자열을 절반으로 나누고, 앞과 뒤를 비교하여 회문인지 확인
8
+ 3. 회문이면 True, 아니면 False 반환
9
10
+ a = ""
11
+ for i in s.lower():
12
+ if i.isalnum():
13
+ a += i
14
+ for i, j in zip(a[:len(a) // 2], a[len(a):(len(a) // 2 - 1):-1]):
15
+ if i != j:
16
+ return False
17
+ return True
0 commit comments