I completed arrays yesterday so Today let’s solve a string question
Question link: https://leetcode.com/problems/valid-palindrome/description/
Extract the words. Reverse the words list with space character in between and finally return the list version of the string
TASKs
def isPalindrome(s):
str = ''.join(e.lower() for e in s if e.isalnum() )
return str == str[::-1]
Why?
TC: O(n)
SC: O(n)