![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
Crush-lph
这个作者很懒,什么都没留下…
展开
-
js实现反转链表
//js中是没有链表的,但是我们可以用对象的引用来模拟一个链表 // 首先创建一个链表 function CreateNode(data){ this.data = data this.next = null}let a = CreateNode(1)let b = CreateNode(2)let c = CreateNode(3)a.next = bb.next = c//此时我们的链表创建完成 // 打印列表function printLst(head){ whil原创 2021-11-22 22:33:43 · 3817 阅读 · 0 评论 -
js实现有序数组的二分查找
// 递归function indexOf(arr,target,start,end){ start = start||0 end = end||arr.length-1; if(start>end){ return -1 } let mid = Math.floor((start+end)/2) if(arr[mid]>target){ end = mid-1 return indexOf(arr,target,start,end) }el原创 2021-11-22 22:32:41 · 3461 阅读 · 0 评论 -
利用栈的思想解决括号闭合的问题(javascript)
var str = []{}() function tagMatch(str) { if (!str) { console.log('false'); return false } const stack = [] const tagArr = str.split('') let lastTag = null tagArr.map((item, index) => { // if.原创 2021-11-19 13:07:39 · 643 阅读 · 0 评论