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 6f2210e commit ac4ef44Copy full SHA for ac4ef44
โvalid-palindrome/radiantchoi.pyโ
@@ -0,0 +1,12 @@
1
+class Solution:
2
+ def isPalindrome(self, s: str) -> bool:
3
+ # ์ ์ ์ ์ผ๋ก ์๋ฌธ์๋ก ๋ฐ๊พผ ๋ฌธ์์ด์์ ์ํ๋ฒณ์ด๋ ์ซ์์ธ์ง๋ฅผ ๊ฑธ๋ฌ ๋ธ๋ค.
4
+ s = list(filter(lambda x: x.isalnum(), s.lower()))
5
+
6
+ # ์ฒ์๊ณผ ๋์์ ๊ฐ๊ฐ ํ ์นธ์ฉ ์ขํ์ง๋ ์ธ๋ฑ์ค์ ๊ตฌํ์ ์ํด ๋ฐฐ์ด์ ์ ๋ฐ๊น์ง๋ง ์ํ
7
+ # ๊ฐ์ ์๊ณ์ ์๋ ๊ธ์๊ฐ ๊ฐ์ง ์์ ๊ฒฝ์ฐ early return
8
+ for i in range(len(s) // 2):
9
+ if s[i] != s[len(s) - i - 1]:
10
+ return False
11
12
+ return True
0 commit comments