Python String Parsing

Check Valid Palindrome

words = [‘a’, ‘b’, ‘c’, ‘b’, ‘a’]

While len(words) > 1:

— — — — if words.pop(0) !=words.pop():

— — — — — — — — return False

Using Deque, the code can optimize the performance in speed. Deques is BigO(n)

def isPalindrome(self, s: str): -> bool:

— — — — strs: Deque = collections.deque()

— — — — for char in s:

— — — — —if char.isalum():

— — — — — — —strs.append(char.lower())

while len(strs) > 1:

— — — — if strs.popleft() !=strs.pop():

— — — — — — return False

return True

Slicing이 가장 속도가 빠르다.

--

--

Education is key to success why developers are desperately learning every day.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Devedunkey

Education is key to success why developers are desperately learning every day.