Skip to content

Commit 55525b4

Browse files
committed
再次优化README 增加数据结构部分内容
1 parent 21506ef commit 55525b4

File tree

19 files changed

+308
-47
lines changed

19 files changed

+308
-47
lines changed

.DS_Store

-2 KB
Binary file not shown.

.idea/misc.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.obsidian/plugins/recent-files-obsidian/data.json

+42-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,53 @@
55
"path": "README.md"
66
},
77
{
8-
"basename": "51. N 皇后",
9-
"path": "2. coding/51. N 皇后.md"
8+
"basename": "index",
9+
"path": "1. cs/《Problem solving with algorithms and Data Structures Using Python》/线性数据结构/index.md"
1010
},
1111
{
1212
"basename": "index",
1313
"path": "2. coding/index.md"
1414
},
15+
{
16+
"basename": "内推模板",
17+
"path": "temp/内推模板.md"
18+
},
19+
{
20+
"basename": "DOM检查 ?react 解析器?开源工具?",
21+
"path": "DOM检查 ?react 解析器?开源工具?.md"
22+
},
23+
{
24+
"basename": "leetcode 拷贝题目模板",
25+
"path": "temp/leetcode 拷贝题目模板.md"
26+
},
27+
{
28+
"basename": "index",
29+
"path": "1. cs/《Problem solving with algorithms and Data Structures Using Python》/index.md"
30+
},
31+
{
32+
"basename": "操作系统层面的调用栈管理?",
33+
"path": "操作系统层面的调用栈管理?.md"
34+
},
35+
{
36+
"basename": "",
37+
"path": "1. cs/《Problem solving with algorithms and Data Structures Using Python》/线性数据结构/栈.md"
38+
},
39+
{
40+
"basename": "何为数据结构与算法?",
41+
"path": "1. cs/《Problem solving with algorithms and Data Structures Using Python》/何为数据结构与算法?.md"
42+
},
43+
{
44+
"basename": "浏览器历史管理",
45+
"path": "浏览器历史管理.md"
46+
},
47+
{
48+
"basename": "Pasted image 20220102214927",
49+
"path": "static/Pasted image 20220102214927.png"
50+
},
51+
{
52+
"basename": "51. N 皇后",
53+
"path": "2. coding/51. N 皇后.md"
54+
},
1555
{
1656
"basename": "index",
1757
"path": "3. sd/FE/index.md"
@@ -48,10 +88,6 @@
4888
"basename": "59. 螺旋矩阵 II",
4989
"path": "2. coding/59. 螺旋矩阵 II.md"
5090
},
51-
{
52-
"basename": "leetcode 拷贝题目模板",
53-
"path": "temp/leetcode 拷贝题目模板.md"
54-
},
5591
{
5692
"basename": "59. 螺旋矩阵 II",
5793
"path": "coding/beginner/recursion/59. 螺旋矩阵 II.md"

.obsidian/workspace

+12-24
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,15 @@
44
"type": "split",
55
"children": [
66
{
7-
"id": "6db266198f75c765",
7+
"id": "2cf85588b3df5d0a",
88
"type": "leaf",
99
"state": {
1010
"type": "markdown",
1111
"state": {
1212
"file": "README.md",
1313
"mode": "preview"
1414
}
15-
},
16-
"group": "7fe7d837d39d8f54"
17-
},
18-
{
19-
"id": "fc6256f5f8f939fc",
20-
"type": "leaf",
21-
"state": {
22-
"type": "outline",
23-
"state": {
24-
"file": "README.md"
25-
}
26-
},
27-
"group": "7fe7d837d39d8f54"
15+
}
2816
}
2917
],
3018
"direction": "vertical"
@@ -80,7 +68,7 @@
8068
}
8169
],
8270
"direction": "horizontal",
83-
"width": 351.49999809265137
71+
"width": 718.9999980926514
8472
},
8573
"right": {
8674
"id": "c2caebd2760df946",
@@ -125,17 +113,17 @@
125113
"width": 255.35166931152344,
126114
"collapsed": true
127115
},
128-
"active": "6db266198f75c765",
116+
"active": "2cf85588b3df5d0a",
129117
"lastOpenFiles": [
130118
"README.md",
131-
"2. coding/51. N 皇后.md",
119+
"1. cs/《Problem solving with algorithms and Data Structures Using Python》/线性数据结构/index.md",
132120
"2. coding/index.md",
133-
"3. sd/FE/index.md",
134-
"2. coding/2-training/198.打家劫舍.md",
135-
"coding/2-training/213.打家劫舍 II.md",
136-
"2. coding/1-beginner/1. sorting/283. 移动零.md",
137-
"log/2022年计划.md",
138-
"coding/1-beginner/beginer - index.md",
139-
"2. coding/2-training/index.md"
121+
"temp/内推模板.md",
122+
"DOM检查 ?react 解析器?开源工具?.md",
123+
"temp/leetcode 拷贝题目模板.md",
124+
"1. cs/《Problem solving with algorithms and Data Structures Using Python》/index.md",
125+
"操作系统层面的调用栈管理?.md",
126+
"1. cs/《Problem solving with algorithms and Data Structures Using Python》/线性数据结构/栈.md",
127+
"1. cs/《Problem solving with algorithms and Data Structures Using Python》/何为数据结构与算法?.md"
140128
]
141129
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Table of Contents
2+
3+
> ❗️ 只记录书中讲述的重点内容,以及补充以下链接关系:
4+
> - 数据结构的工业应用
5+
> - 经典/有趣/ leetcode题
6+
7+
[[何为数据结构与算法?]]
8+
9+
10+
[[1. cs/《Problem solving with algorithms and Data Structures Using Python》/线性数据结构/index]]
11+

1. cs/《Problem solving with algorithms and Data Structures Using Python》/何为数据结构与算法?.md

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 线性数据结构
2+
3+
- 理解何为线性
4+
- 基本ADT:栈、队列、双端队列和列表
5+
6+
7+
## 线性(属性)定义
8+
9+
1. 有序的数据集合,其元素的顺序由添加和删除时机决定
10+
2. 删除/新增元素到集合中时,不会影响其他元素的相对位置
11+
12+
## 重要结构
13+
14+
1. [[]]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class MyStack:
2+
def __init__(self):
3+
self.items = []
4+
5+
def is_empty(self) -> bool:
6+
return len(self.items) == 0
7+
8+
# def push(self, item):
9+
# self.items.append(item)
10+
11+
def push(self, item):
12+
self.items.insert(0, item)
13+
14+
# def pop(self):
15+
# return self.items.pop()
16+
17+
def pop(self):
18+
return self.items.pop(0)
19+
20+
# 如何使用切片和解构返回顶部元素呢?
21+
def peek(self):
22+
return self.items[len(self.items) - 1]
23+
24+
def size(self):
25+
return len(self.items)
26+
27+
28+
stack = MyStack()
29+
30+
stack.push('1')
31+
print(stack.size())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#
2+
3+
## 性质
4+
5+
### 性质1: LIFO
6+
7+
提供一种基于数据停留在集合中的时间来排序的方式,时长短的在顶部,反之在底部。
8+
9+
### 性质2: 反转(盗梦空间)
10+
11+
## ADT 与实现
12+
13+
### ADT
14+
15+
- Stack()创建一个空栈。它不需要参数,且会返回一个空栈。
16+
- push(item)将一个元素添加到栈的顶端。它需要一个参数 item,且无返回值。
17+
- pop()将栈顶端的元素移除。它不需要参数,但会返回顶端的元素,并且修改栈的内容。
18+
- peek()返回栈顶端的元素,但是并不移除该元素。它不需要参数,也不会修改栈的内容。
19+
- isEmpty()检查栈是否为空。它不需要参数,且会返回一个布尔值。
20+
- size()返回栈中元素的数目。它不需要参数,且会返回一个整数。
21+
22+
![[Pasted image 20220102214934.png]]
23+
24+
### 实现
25+
26+
#### 要点
27+
28+
1. “有序”排列
29+
2. 考虑栈顶使用列表的哪个位置
30+
31+
#### 基于列表尾部/头部
32+
33+
```python
34+
class MyStack:
35+
def __init__(self):
36+
self.items = []
37+
38+
def is_empty(self) -> bool:
39+
return len(self.items) == 0
40+
41+
# def push(self, item):
42+
# self.items.append(item)
43+
def push(self, item):
44+
self.items.insert(0, item)
45+
46+
# def pop(self):
47+
# return self.items.pop()
48+
def pop(self):
49+
return self.items.pop(0)
50+
51+
# 如何使用切片和解构返回顶部元素呢?
52+
def peek(self):
53+
return self.items[len(self.items) - 1]
54+
55+
def size(self):
56+
return len(self.items)
57+
```
58+
59+
60+
## 经典案例
61+
62+
### 进制转化
63+
64+
### (前、中、后)序表达式转化
65+
66+
67+
- [ ] [20. 有效的括号](https://leetcode-cn.com/problems/valid-parentheses/)
68+
- [ ] [853. 车队](https://leetcode-cn.com/problems/car-fleet/)
69+
- [ ] [735. 行星碰撞](https://leetcode-cn.com/problems/asteroid-collision/)
70+
71+
盗梦空间
72+
73+
[1047. 删除字符串中的所有相邻重复项](https://leetcode-cn.com/problems/remove-all-adjacent-duplicates-in-string/)
74+
[150. 逆波兰表达式求值](https://leetcode-cn.com/problems/evaluate-reverse-polish-notation/)
75+
[736. Lisp 语法解析](https://leetcode-cn.com/problems/parse-lisp-expression/)
76+
[224. 基本计算器](https://leetcode-cn.com/problems/basic-calculator/)
77+
[241. 为运算表达式设计优先级](https://leetcode-cn.com/problems/different-ways-to-add-parentheses/)
78+
79+
80+
## 课后思考
81+
82+
### 工业应用
83+
84+
[[浏览器历史管理]]
85+
- [ ] [1472. 设计浏览器历史记录](https://leetcode-cn.com/problems/design-browser-history/)
86+
87+
#### HTML词法解析
88+
89+
[[DOM检查 ?react 解析器?开源工具?]]
90+
91+
- [ ] [591. 标签验证器](https://leetcode-cn.com/problems/tag-validator/)
92+
93+
### 高级话题
94+
95+
[[操作系统层面的调用栈管理?]]

2. coding/3-contest/274/1.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @param {number} mass
3+
* @param {number[]} asteroids
4+
* @return {boolean}
5+
*/
6+
var asteroidsDestroyed = function(mass, asteroids) {
7+
asteroids.sort((a,b) => a - b);
8+
let m = mass;
9+
for(let i = 0; i < asteroids.length;i++) {
10+
if(m < asteroids[i]) return false;
11+
m += asteroids[i]
12+
}
13+
return true
14+
};
15+
16+
17+
// 3

2. coding/3-contest/274/2.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @param {string[]} bank
3+
* @return {number}
4+
*/
5+
var numberOfBeams = function(bank) {
6+
let cnt = 0;
7+
for(let i = 0;i < bank.length;i++) {
8+
let upCnt = getCount(bank[i]);
9+
if(upCnt === 0) continue;
10+
11+
for(let j = i + 1;j < bank.length;j++) {
12+
let downCnt = getCount(bank[j]);
13+
if(downCnt === 0) continue;
14+
console.log(upCnt,downCnt)
15+
cnt += upCnt * downCnt;
16+
break;
17+
}
18+
19+
}
20+
return cnt;
21+
};
22+
23+
function getCount(str) {
24+
let cnt = 0;
25+
for(let c of str) {
26+
if (c === '1') cnt += 1
27+
}
28+
return cnt
29+
}
30+
31+
console.log(numberOfBeams(["011001","000000","010100","001000"]))

2. coding/3-contest/274/3.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var checkString = function(s) {
6+
7+
for(let i = 0;i < s.length;i++) {
8+
if(s[i] !== 'b') {
9+
continue;
10+
}
11+
// check after
12+
for(let j = i + 1;j < s.length;j++) {
13+
if(s[j] === 'a') return false
14+
}
15+
}
16+
return true
17+
};
18+
console.log(checkString("aaabbb"))

2. coding/3-contest/274/4.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @param {number[]} favorite
3+
* @return {number}
4+
*/
5+
var maximumInvitations = function(favorite) {
6+
7+
};

0 commit comments

Comments
 (0)