上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 36 下一页
摘要: 只移动0,其他顺序不变;必须在元素组进行操作 会改变原数组内的值类型 const moveZeroByReg = (arr = [1,0,2,0,3,0,4,0,5]) => { const reg = /0/g let str = arr.join('') const res = str.matc 阅读全文
posted @ 2023-01-27 02:23 671_MrSix 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 逻辑结构 VS 物理结构 堆:逻辑结构是一颗二叉树(如下图) 物理结构是一个数组(如下代码) // 上图是一个堆(从小到大)可以用数组表示 const heap = [-1, 10, 14, 25, 33, 81, 82, 99] // 忽略下标0 // 节点关系 const parentindex 阅读全文
posted @ 2023-01-27 00:48 671_MrSix 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 循环实现 const binarySearchTree = (node = tree, target = 8) => { let curNode = node while(true){ if(!curNode){ return false } if(curNode.value > target){ 阅读全文
posted @ 2023-01-27 00:25 671_MrSix 阅读(14) 评论(0) 推荐(0) 编辑
摘要: /** * 注意:left/right值若没有显示设置为null,值即为undefined * 在调用二叉树前、中、后序遍历方法时,由于参数设置了默认值(tree) * 所以进入了死循环 */ const tree = { value: 5, left: { value: 3, left: { va 阅读全文
posted @ 2023-01-27 00:07 671_MrSix 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 链表 -> 队列 class QueueByLinkList{ #head = null #tail = null #len = 0 add(value){ const newNode = { value, next: null } if(!this.#head){ this.#head = new 阅读全文
posted @ 2023-01-26 18:14 671_MrSix 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 数组生成单向链表 const createLinkList = (array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) => { let root = null; for (let index = 0; index < array.length; index++) { co 阅读全文
posted @ 2023-01-26 16:55 671_MrSix 阅读(9) 评论(0) 推荐(0) 编辑
摘要: #code class Queue { #stack1 = [] #stack2 = [] add(value){ this.#stack1.push(value) return this.#stack1.length } delete(){ while(this.#stack1.length){ 阅读全文
posted @ 2023-01-26 00:53 671_MrSix 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 时间复杂度O(n^2) const rorateKstep = (arr = [1,2,3,4,5,6,7],step = 3) => { for(let i = 0; i < 3;i++){ arr.unshift(arr.pop()) } return arr } 时间复杂度O(1) const 阅读全文
posted @ 2023-01-25 23:10 671_MrSix 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 在编写网站的时候,或多或少都会用到一些网络上的字体,CSS3中虽然加入了对 Web Fonts(网络字体)的支持,但是浏览器对它们的加载和默认处理方式会极大的影响网站的性能和用户体验。例如默认情况下,在 Web Fonts 加载时,使用该字体的地方会显示空白,直到字体下载完成之后才会显示,这时通过改 阅读全文
posted @ 2023-01-25 01:41 671_MrSix 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 手动枚举所有成员 function convertToArray(nodes){ let array = null try { array = Array.prototype.slice.call(nodes,0) } catch (error) { array = new Array for(le 阅读全文
posted @ 2023-01-25 01:16 671_MrSix 阅读(6) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 36 下一页