2020年11月23日
摘要: “要理解递归,首先要理解递归。” 递归通常涉及函数调用自身。 每个递归函数都必须有基线条件,即一个不再递归调用的条件(停止点),以防止无限递归。 1.阶乘 n! = n * (n-1) * (n -2) .... * 2 * 1 迭代阶乘 function factorialIterative(n) 阅读全文
posted @ 2020-11-23 17:42 chen_coder 阅读(109) 评论(0) 推荐(0)
2020年11月19日
摘要: 字典 在字典中,存储的是[键,值]对,其中键名是用来查询特定元素的。字典和集合很相似,集合以[值,值]的形式存储元素,字 典则是以[键,值]的形式来存储元素。字典也称作映射、符号表或关联数组。 import { defaultToString } from '../util'; import { V 阅读全文
posted @ 2020-11-19 21:11 chen_coder 阅读(152) 评论(0) 推荐(0)
2020年11月17日
摘要: 集合是由一组无序且唯一(即不能重复)的项组成的。 创建集合类 class Set { constructor() { this.items = {}; } //首先要实现的是 has(element)方法,因为它会被 add、delete 等其他方法调用。如果元素在集合中,返回 true,否则返回 阅读全文
posted @ 2020-11-17 14:35 chen_coder 阅读(108) 评论(0) 推荐(0)
摘要: 756.蛇形矩阵 #题目:输入两个整数n和m,输出一个n行m列的矩阵,将数字 1 到 n*m 按照回字蛇形填充至矩阵中。 #输入: #3 3 #输出: # 1 2 3 # 8 9 4 # 7 6 5 n, m = map(int, input().strip().split()) # 以垂直向下为x 阅读全文
posted @ 2020-11-17 11:02 chen_coder 阅读(253) 评论(0) 推荐(0)
摘要: 需求:想通过python生成m行n列的矩阵 方式1:(有问题) data = [[0]*3]*4 #4行3列 print(data) #[[0, 0, 0], [0, 0, 0], [0, 0, 0], [0, 0, 0]] 赋值 data[0][0] = 1 print(data) #[[1, 0 阅读全文
posted @ 2020-11-17 09:53 chen_coder 阅读(1907) 评论(0) 推荐(1)
2020年11月16日
摘要: 链表中的元素在内存中并不是连续放置的。每个元素由一个存储元素本身的节点和一个指向下一个元素的引用(也称指针或链接)组成 单链表 import { defaultEquals } from '../util'; class Node { constructor(key) { this.key = ke 阅读全文
posted @ 2020-11-16 15:18 chen_coder 阅读(110) 评论(0) 推荐(0)
摘要: 队列数据结构 队列是遵循先进先出原则的一组有序的项。队列在尾部添加新元素,并从顶部移除元素 class Queue{ constructor(){ this.count = 0;//控制队列大小 this.lowestCount = 0;//需要重队列前端删除,使用一个变量追踪第一个元素 this. 阅读全文
posted @ 2020-11-16 13:57 chen_coder 阅读(96) 评论(0) 推荐(0)
2020年10月24日
摘要: .triangle{ border-top: 50px solid #ff0000; border-bottom: 50px solid #00a000; border-left: 50px solid #ff7f50; border-right: 50px solid #436eee; } 因为此 阅读全文
posted @ 2020-10-24 17:58 chen_coder 阅读(129) 评论(0) 推荐(0)