随笔分类 -  js数据结构与算法

摘要:逻辑如图 代码(栈的类看上一篇): function parentheseChecker(symbols){ const stack = new Stack(); const opens='([{'; const closes=')]}'; let balanced = true; let inde 阅读全文
posted @ 2022-01-13 15:07 she_will 阅读(256) 评论(0) 推荐(0)
摘要:1、定义一个栈的类 class Stack{ constructor(){ this.items=[] } // 从栈顶添加元素 push(ele){ this.items.push(ele) } // 从栈移除元素 pop(){ return this.items.pop() } // 查看栈顶元 阅读全文
posted @ 2022-01-12 17:18 she_will 阅读(242) 评论(0) 推荐(0)