Skip to content

Commit 89739e6

Browse files
committed
fix solution: update comment
1 parent e6c66d5 commit 89739e6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

valid-palindrome/dusunax.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'''
22
# Leetcode 125. Valid Palindrome
33
4-
use regex to filter out non-alphanumeric characters 🔍
4+
use `isalnum()` to filter out non-alphanumeric characters 🔍
55
66
## Time and Space Complexity
77
@@ -11,10 +11,12 @@
1111
```
1212
1313
### TC is O(n):
14-
- iterating through the string just once to filter out non-alphanumeric characters.
14+
- iterating through the string just once to filter out non-alphanumeric characters. O(n)
1515
1616
### SC is O(n):
17-
- creating a new string to store the filtered characters.
17+
- `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)
1820
'''
1921

2022
class Solution:

0 commit comments

Comments
 (0)