Skip to content

Commit b5e517f

Browse files
committed
builtin
1 parent bd13a27 commit b5e517f

File tree

1 file changed

+12
-12
lines changed
  • docs/19_python内置常用算法和数据结构

1 file changed

+12
-12
lines changed

docs/19_python内置常用算法和数据结构/builtins.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212

1313
下边我列了一个常用 python 内置数据结构和算法的表格,如果有遗漏可以在 issue 中提出。确保你了解这些数据结构和算法的使用以及时间、空间复杂度。
1414

15-
| 数据结构/算法 | 语言内置 | 内置库 |
16-
|---------------|---------------------------------|---------------------------------------------------------------|
17-
| 线性结构 | list(列表)/tuple(元祖) | array(数组,不常用)/collections.namedtuple |
18-
| 链式结构 | | collections.deque(双端队列) |
19-
| 字典结构 | dict(字典) | collections.Counter(计数器)/OrderedDict(有序字典)/defaultdict |
20-
| 集合结构 | set(集合)/frozenset(不可变集合) | |
21-
| 排序算法 | sorted | |
22-
| 二分算法 | | bisect模块 |
23-
| 堆算法 | | heapq模块 |
24-
| 优先级队列 | | queue.PriorityQueue |
25-
| 缓存算法 | | functools.lru_cache(Least Recent Used, python3) |
15+
| 数据结构/算法 | 语言内置 | 内置库 |
16+
|---------------|---------------------------------|-------------------------------------------------------------------------|
17+
| 线性结构 | list(列表)/tuple(元祖) | array(数组,不常用)/collections.namedtuple |
18+
| 链式结构 | | collections.deque(双端队列) |
19+
| 字典结构 | dict(字典) | collections.Counter(计数器)/OrderedDict(有序字典)/defaultdict(默认字典) |
20+
| 集合结构 | set(集合)/frozenset(不可变集合) | |
21+
| 排序算法 | sorted | |
22+
| 二分算法 | | bisect模块 |
23+
| 堆算法 | | heapq模块 |
24+
| 优先级队列 | | queue.PriorityQueue/heapq |
25+
| 缓存算法 | | functools.lru_cache(Least Recent Used, python3) |
2626

2727
# 一些坑
2828

29-
如果你经常使用 python2 or python3 刷题(比如力扣leetcode),有一些坑或者技巧需要注意:
29+
如果你使用 python2 or python3 刷题(比如力扣leetcode),有一些坑或者技巧需要注意:
3030

3131
- python3 和 python2 的 dict 有所用不同,python3.7 之后的 dict 会保持插入顺序, python2 不要依赖 dict 迭代顺序,请使用 OrderedDict
3232
- 正确初始化一个二维数组:`dp = [[0 for _ in range(col)] for _ in range(row)]`,不要用 `dp = [[0] * n] * m`, 否则里边都

0 commit comments

Comments
 (0)