摘要: 这个双端链表继承了单链表的一些属性,详情请见:https://www.cnblogs.com/MySweetheart/p/13212220.html 1.创建一个双端节点 class DoublyNode extends Node{ constructor(element,next,prev){ 阅读全文
posted @ 2020-06-30 11:22 放学别跑啊 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1.创建链表节点 class Node{ constructor(element,next){ this.element = element; this.next = next; } } 2.创建一个比较函数 function defaultEquals(a , b){ return a == b; 阅读全文
posted @ 2020-06-30 10:15 放学别跑啊 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 代码如下: function palidromeChecker(aString){ if(aString undefined || aString null || (aString != null && aString.length == 0)){ return false; } const deq 阅读全文
posted @ 2020-06-30 09:13 放学别跑啊 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 这个击鼓传花基于普通的队列级基础上变为循环队列,没有使用双端队列,普通的队列可以见我之前发布的文章。击鼓传花代码如下: function hotPotato(elementsList,num){ const queue = new Queue();//这个队列类,可以参考https://www.cn 阅读全文
posted @ 2020-06-30 08:57 放学别跑啊 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 1.双端队列,一种允许我们从队列的前面和后面添加和删除元素的队列。 2.创建一个双端队列的类 class Deque{ constructor(){ this.lowestCount = 0; this.count = 0; this.items = {}; } } 3.判断队列是否为空 isEmp 阅读全文
posted @ 2020-06-30 08:35 放学别跑啊 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 1.队列是遵循先进先出(FIFO)原则的一组有序的项,队列在尾部添加元素,并从顶部移除元素,最新添加的元素必须排在队列的末尾。生活中常见的例子如排队等。 2.创建一个队列类 class Queue{ constructor(){ this.count = 0;//记录队列的数量 this.lowes 阅读全文
posted @ 2020-06-30 07:55 放学别跑啊 阅读(737) 评论(0) 推荐(0) 编辑