MCPcopy Index your code
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / palcheker

Function palcheker

Queue.py:61–75  ·  view source on GitHub ↗
(aString)

Source from the content-addressed store, hash-verified

59
60# 利用Deque解决回文字符串
61def palcheker(aString):
62 chardeque = Deque()
63
64 for ch in aString:
65 chardeque.addFront(ch)
66
67 stillEqual = True
68
69 while chardeque.size() > 1 and stillEqual:
70 first = chardeque.removeFront()
71 last = chardeque.removeRear()
72 if first != last:
73 stillEqual = False
74
75 return stillEqual
76
77print(palcheker('lsdkjfskf'))
78print(palcheker('radar'))

Callers 1

Queue.pyFile · 0.85

Calls 5

addFrontMethod · 0.95
sizeMethod · 0.95
removeFrontMethod · 0.95
removeRearMethod · 0.95
DequeClass · 0.85

Tested by

no test coverage detected