(aString)
| 59 | |
| 60 | # 利用Deque解决回文字符串 |
| 61 | def 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 | |
| 77 | print(palcheker('lsdkjfskf')) |
| 78 | print(palcheker('radar')) |
no test coverage detected