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 638a517 commit 3251a99Copy full SHA for 3251a99
1 file changed
valid-palindrome/jylee2033.py
@@ -0,0 +1,14 @@
1
+class Solution:
2
+ def isPalindrome(self, s: str) -> bool:
3
+ # 1. Remove non-alphanumeric characters and convert to lowercase
4
+ # 2. Compare with reversed string
5
+
6
+ cleaned_s = ""
7
+ for ch in s:
8
+ if ch.isalnum():
9
+ cleaned_s += ch.lower()
10
11
+ return cleaned_s == cleaned_s[::-1]
12
13
+# Time Complexity : O(n)
14
+# Space Complexity : O(n)
0 commit comments