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 e6c66d5 commit 89739e6Copy full SHA for 89739e6
valid-palindrome/dusunax.py
@@ -1,7 +1,7 @@
1
'''
2
# Leetcode 125. Valid Palindrome
3
4
-use regex to filter out non-alphanumeric characters 🔍
+use `isalnum()` to filter out non-alphanumeric characters 🔍
5
6
## Time and Space Complexity
7
@@ -11,10 +11,12 @@
11
```
12
13
### TC is O(n):
14
-- iterating through the string just once to filter out non-alphanumeric characters.
+- iterating through the string just once to filter out non-alphanumeric characters. O(n)
15
16
### SC is O(n):
17
-- creating a new string to store the filtered characters.
+- `s.lower()` creates a new string. O(n)
18
+- creating a new string `converted_s` to store the filtered characters. O(n)
19
+- `converted_s[::-1]` creates a new reversed string. O(n)
20
21
22
class Solution:
0 commit comments