什么是回文
回文是正反都能读通的单词,词组,数或一些列字符的序列,例如 madam 与 racecar。
如何实现回文检查其的功能
如上所述,回文是一些正反颠倒都能和之前的值一样的序列。那么我们只需要抽出第一位与最后一位,第二位与倒数第二位来对比即可。
class Deque {
constructor() {
this.count = 0;
this.lowestCount = 0;
this.items = {
};
}
size() {
return this.count - this.lowestCount; }
addFront(element) {
if ( this.isEmpty() ) this.addBack(element);
else if ( this.lowestCount > 0 )