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 307356c commit 6151023Copy full SHA for 6151023
1 file changed
โvalid-palindrome/gcount85.pyโ
@@ -0,0 +1,27 @@
1
+"""
2
+# Approach
3
+์ ๋์ ํฌ์ธํฐ๋ฅผ ๋๊ณ ํ์ด์ฌ์ isalnum(), lower() ๋ฌธ์์ด ๋ฉ์๋๋ก ๊ฒ์ฌํฉ๋๋ค.
4
+
5
+# Complexity
6
+- Time complexity: s์ ๊ธธ์ด๋ฅผ N์ด๋ผ๊ณ ํ ๋, O(N)
7
8
+- Space complexity: O(1)
9
10
11
12
+class Solution:
13
+ def isPalindrome(self, s: str) -> bool:
14
+ l = 0
15
+ r = len(s) - 1
16
+ while l < r:
17
+ if not s[l].isalnum():
18
+ l += 1
19
+ continue
20
+ if not s[r].isalnum():
21
+ r -= 1
22
23
+ if s[l].lower() != s[r].lower():
24
+ return False
25
26
27
+ return True
0 commit comments