Skip to content

Commit fddf428

Browse files
committed
2 parents 6a24574 + 9aa4202 commit fddf428

File tree

7 files changed

+35
-36
lines changed

7 files changed

+35
-36
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,25 +208,28 @@ Power by [logomakr](https://logomakr.com/).
208208
感谢以下人员对本仓库做出的贡献,当然不仅仅只有这些贡献者,这里就不一一列举了。如果你希望被添加到这个名单中,并且提交过 Issue 或者 PR,请与笔者联系。
209209

210210
<a href="https://github.com/linw7">
211-
<img src="other/21679154.png" width="50px">
211+
<img src="https://avatars3.githubusercontent.com/u/21679154?s=400&v=4" width="50px">
212212
</a>
213213
<a href="https://github.com/g10guang">
214-
<img src="other/18458140.jpg" width="50px">
214+
<img src="https://avatars1.githubusercontent.com/u/18458140?s=400&v=4" width="50px">
215215
</a>
216216
<a href="https://github.com/ResolveWang">
217-
<img src="other/8018776.jpg" width="50px">
217+
<img src="https://avatars1.githubusercontent.com/u/8018776?s=400&v=4" width="50px">
218218
</a>
219219
<a href="https://github.com/crossoverJie">
220-
<img src="other/15684156.jpg" width="50px">
220+
<img src="https://avatars1.githubusercontent.com/u/15684156?s=400&v=4" width="50px">
221221
</a>
222222
<a href="https://github.com/jy03078584">
223-
<img src="other/7719370.png" width="50px">
223+
<img src="https://avatars2.githubusercontent.com/u/7719370?s=400&v=4" width="50px">
224224
</a>
225225
<a href="https://github.com/kwongtailau">
226-
<img src="other/22954582.jpg" width="50px">
226+
<img src="https://avatars0.githubusercontent.com/u/22954582?s=400&v=4" width="50px">
227227
</a>
228228
<a href="https://github.com/xiangflight">
229-
<img src="other/10072416.jpg" width="50px">
229+
<img src="https://avatars2.githubusercontent.com/u/10072416?s=400&v=4" width="50px">
230+
</a>
231+
<a href="https://github.com/mafulong">
232+
<img src="https://avatars1.githubusercontent.com/u/24795000?s=400&v=4" width="50px">
230233
</a>
231234

232235
#### License

notes/Java 容器.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ HashMap 构造函数允许用户传入的容量不是 2 的 n 次方,因为它
738738

739739
```
740740
mask |= mask >> 1 11011000
741-
mask |= mask >> 2 11111100
741+
mask |= mask >> 2 11111110
742742
mask |= mask >> 4 11111111
743743
```
744744

notes/Leetcode 题解.md

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,35 +2415,27 @@ public int climbStairs(int n) {
24152415
定义 dp 数组用来存储最大的抢劫量,其中 dp[i] 表示抢到第 i 个住户时的最大抢劫量。
24162416

24172417
由于不能抢劫邻近住户,因此如果抢劫了第 i 个住户那么只能抢劫 i - 2 或者 i - 3 的住户,所以
2418-
2419-
<div align="center"><img src="https://latex.codecogs.com/gif.latex?dp[i]=max(dp[i-2],dp[i-3])+nums[i]"/></div> <br>
2418+
dp[i] = max(dp[i-1], dp[i-2] + nums[i]) <br>
24202419

24212420
```java
24222421
public int rob(int[] nums) {
2423-
int n = nums.length;
2424-
if (n == 0) {
2425-
return 0;
2426-
}
2427-
if (n == 1) {
2428-
return nums[0];
2429-
}
2430-
int pre3 = 0, pre2 = 0, pre1 = 0;
2431-
for (int i = 0; i < n; i++) {
2432-
int cur = Math.max(pre2, pre3) + nums[i];
2433-
pre3 = pre2;
2422+
int pre2 = 0, pre1 = 0;
2423+
for (int i = 0; i < nums.length; i++) {
2424+
int cur = Math.max(pre2 + nums[i], pre1);
24342425
pre2 = pre1;
24352426
pre1 = cur;
24362427
}
2437-
return Math.max(pre1, pre2);
2428+
return pre1;
24382429
}
2430+
24392431
```
24402432

24412433
**强盗在环形街区抢劫**
24422434

24432435
[213. House Robber II (Medium)](https://leetcode.com/problems/house-robber-ii/description/)
24442436

24452437
```java
2446-
public int rob(int[] nums) {
2438+
public int rob(int[] nums) {
24472439
if (nums == null || nums.length == 0) {
24482440
return 0;
24492441
}
@@ -2454,15 +2446,14 @@ public int rob(int[] nums) {
24542446
return Math.max(rob(nums, 0, n - 2), rob(nums, 1, n - 1));
24552447
}
24562448

2457-
private int rob(int[] nums, int first, int last) {
2458-
int pre3 = 0, pre2 = 0, pre1 = 0;
2449+
private int rob(int[] nums, int first, int last) {
2450+
int pre2 = 0, pre1 = 0;
24592451
for (int i = first; i <= last; i++) {
2460-
int cur = Math.max(pre3, pre2) + nums[i];
2461-
pre3 = pre2;
2452+
int cur = Math.max(pre1, pre2 + nums[i]);
24622453
pre2 = pre1;
24632454
pre1 = cur;
24642455
}
2465-
return Math.max(pre2, pre1);
2456+
return pre1;
24662457
}
24672458
```
24682459

@@ -2514,9 +2505,9 @@ public int minPathSum(int[][] grid) {
25142505
for (int i = 0; i < m; i++) {
25152506
for (int j = 0; j < n; j++) {
25162507
if (i == 0) {
2517-
dp[j] = dp[j - 1];
2508+
if (j>0) dp[j] = dp[j - 1];
25182509
} else {
2519-
dp[j] = Math.min(dp[j - 1], dp[j]);
2510+
if (j>0) dp[j] = Math.min(dp[j - 1], dp[j]);
25202511
}
25212512
dp[j] += grid[i][j];
25222513
}
@@ -7063,4 +7054,3 @@ public int[] countBits(int num) {
70637054
- 何海涛, 软件工程师. 剑指 Offer: 名企面试官精讲典型编程题[M]. 电子工业出版社, 2014.
70647055
- 《编程之美》小组. 编程之美[M]. 电子工业出版社, 2008.
70657056
- 左程云. 程序员代码面试指南[M]. 电子工业出版社, 2015.
7066-

notes/MySQL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ MySQL 提供了 FROM_UNIXTIME() 函数把 UNIX 时间戳转换为日期,并提
374374

375375
### 2. 连接
376376

377-
可以将原来的连接分解成多个单表连接查询,然后在用户程序中进行连接。
377+
可以将原来的连接分解成多个单表查询,然后在用户程序中进行连接。
378378

379379
### 3. ID 唯一性
380380

notes/分布式.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Zookeeper 提供了一种树形结构级的命名空间,/app1/p_1 节点的父
9999

100100
# 二、分布式事务
101101

102-
指事务的操作位于不同的节点上,需要保证事务的 AICD 特性。
102+
指事务的操作位于不同的节点上,需要保证事务的 ACID 特性。
103103

104104
例如在下单场景下,库存和订单如果不在同一个节点上,就涉及分布式事务。
105105

@@ -335,4 +335,5 @@ Raft 也是分布式一致性协议,主要是用来竞选主节点。
335335
- [What is CAP theorem in distributed database system?](http://www.colooshiki.com/index.php/2017/04/20/what-is-cap-theorem-in-distributed-database-system/)
336336
- [NEAT ALGORITHMS - PAXOS](http://harry.me/blog/2014/12/27/neat-algorithms-paxos/)
337337
- [Paxos By Example](https://angus.nyc/2012/paxos-by-example/)
338+
- [ACID](https://en.wikipedia.org/wiki/ACID_(computer_science))
338339

notes/算法.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public abstract class MergeSort<T extends Comparable<T>> extends Sort<T> {
459459

460460
将一个大数组分成两个小数组去求解。
461461

462-
因为每次都将问题对半分成两个子问题,而这种对半分的算法复杂度一般为 O(NlogN),因此该归并排序方法的时间复杂度也为 O(NlogN)。
462+
因为每次都将问题对半分成两个子问题,这种对半分的算法复杂度一般为 O(NlogN)。
463463

464464
```java
465465
public class Up2DownMergeSort<T extends Comparable<T>> extends MergeSort<T> {
@@ -617,7 +617,7 @@ public class ThreeWayQuickSort<T extends Comparable<T>> extends QuickSort<T> {
617617

618618
可以利用这个特性找出数组的第 k 个元素。
619619

620-
该算法是线性级别的,因为每次能将数组二分,那么比较的总次数为 (N+N/2+N/4+..),直到找到第 k 个元素,这个和显然小于 2N。
620+
该算法是线性级别的,假设每次能将数组二分,那么比较的总次数为 (N+N/2+N/4+..),直到找到第 k 个元素,这个和显然小于 2N。
621621

622622
```java
623623
public T select(T[] nums, int k) {
@@ -2292,7 +2292,7 @@ from H1 to H3
22922292

22932293
可以将每种字符转换成二进制编码,例如将 a 转换为 00,b 转换为 01,c 转换为 10,d 转换为 11。这是最简单的一种编码方式,没有考虑各个字符的权值(出现频率)。而哈夫曼编码采用了贪心策略,使出现频率最高的字符的编码最短,从而保证整体的编码长度最短。
22942294

2295-
首先生成一颗哈夫曼树,每次生成过程中选取频率最少的两个节点,生成一个新节点作为它们的父节点,并且新节点的频率为两个节点的和。选取频率最少的原因是,生成过程使得先选取的节点在树的最底层,那么需要的编码长度更长,频率更少可以使得总编码长度更少。
2295+
首先生成一颗哈夫曼树,每次生成过程中选取频率最少的两个节点,生成一个新节点作为它们的父节点,并且新节点的频率为两个节点的和。选取频率最少的原因是,生成过程使得先选取的节点位于树的更低层,那么需要的编码长度更长,频率更少可以使得总编码长度更少。
22962296

22972297
生成编码时,从根节点出发,向左遍历则添加二进制位 0,向右则添加二进制位 1,直到遍历到叶子节点,叶子节点代表的字符的编码就是这个路径编码。
22982298

notes/系统设计基础.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* [三、扩展性](#三扩展性)
55
* [四、可用性](#四可用性)
66
* [五、安全性](#五安全性)
7+
* [参考资料](#参考资料)
78
<!-- GFM-TOC -->
89

910

@@ -102,3 +103,7 @@
102103
# 五、安全性
103104

104105
要求系统的应对各种攻击手段时能够有可靠的应对措施。
106+
107+
# 参考资料
108+
109+
- 大型网站技术架构:核心原理与案例分析

0 commit comments

Comments
 (0)