isPalindrome

Run Settings
LanguagePython
Language Version
Run Command
# INPUT: String # OUTPUT: Boolean def isPalindrome(s): #starting from 0 i = 0 #starting from end of string j = len(s)-1 while i < j: #ignoring whitespaces and special characters while not s[i].isalnum() and i < j: i+=1 while not s[j].isalnum() and i < j: j-=1 #Checking for equility if s[i].lower() == s[j].lower(): i+=1 j-=1 else: return False return True # # SC: O(1) # TC: O(N) print(isPalindrome("Tooo ot"))
Editor Settings
Theme
Key bindings
Full width
Lines