Skip to content

Commit 2a11c8f

Browse files
committed
auto commit
1 parent 5cdab85 commit 2a11c8f

File tree

6 files changed

+25
-24
lines changed

6 files changed

+25
-24
lines changed

notes/Leetcode 题解.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,28 @@ public int maxSubArray(int[] nums) {
828828
}
829829
```
830830

831+
**买入和售出股票最大的收益**
832+
833+
[121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
834+
835+
题目描述:只进行一次交易。
836+
837+
只要记录前面的最小价格,将这个最小价格作为买入价格,然后将当前的价格作为售出价格,查看当前收益是不是最大收益。
838+
839+
```java
840+
public int maxProfit(int[] prices) {
841+
int n = prices.length;
842+
if (n == 0) return 0;
843+
int soFarMin = prices[0];
844+
int max = 0;
845+
for (int i = 1; i < n; i++) {
846+
if (soFarMin > prices[i]) soFarMin = prices[i];
847+
else max = Math.max(max, prices[i] - soFarMin);
848+
}
849+
return max;
850+
}
851+
```
852+
831853
## 二分查找
832854

833855
**正常实现**
@@ -3340,27 +3362,6 @@ public int maxProfit(int[] prices, int fee) {
33403362
}
33413363
```
33423364

3343-
**买入和售出股票最大的收益**
3344-
3345-
[121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
3346-
3347-
题目描述:只进行一次交易。
3348-
3349-
只要记录前面的最小价格,将这个最小价格作为买入价格,然后将当前的价格作为售出价格,查看当前收益是不是最大收益。
3350-
3351-
```java
3352-
public int maxProfit(int[] prices) {
3353-
int n = prices.length;
3354-
if (n == 0) return 0;
3355-
int soFarMin = prices[0];
3356-
int max = 0;
3357-
for (int i = 1; i < n; i++) {
3358-
if (soFarMin > prices[i]) soFarMin = prices[i];
3359-
else max = Math.max(max, prices[i] - soFarMin);
3360-
}
3361-
return max;
3362-
}
3363-
```
33643365

33653366
**只能进行两次的股票交易**
33663367

notes/Linux.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ dmtsai lines: 5 columns: 9
11771177
- 得到 SIGCHLD 信号;
11781178
- waitpid() 或者 wait() 调用会返回。
11791179

1180-
其中子进程发送的 SIGCHLD 信号包含了子进程的信息,包含了进程 ID、进程状态、进程使用 CPU 的时间等。
1180+
其中子进程发送的 SIGCHLD 信号包含了子进程的信息,比如进程 ID、进程状态、进程使用 CPU 的时间等。
11811181

11821182
在子进程退出时,它的进程描述符不会立即释放,这是为了让父进程得到子进程信息,父进程通过 wait() 和 waitpid() 来获得一个已经退出的子进程的信息。
11831183

notes/计算机操作系统.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ FIFO 常用于客户-服务器应用程序中,FIFO 用作汇聚点,在客户
719719

720720
主要有以下四种方法:
721721

722-
- 鸵鸟策略
722+
- 鸵鸟策略
723723
- 死锁检测与死锁恢复
724724
- 死锁预防
725725
- 死锁避免

notes/设计模式.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,7 @@ public class Client {
23522352

23532353
### Class Diagram
23542354

2355-
<div align="center"> <img src="../pics//0f754c1d-b5cb-48cd-90e0-4a86034290a1.png"/> </div><br>
2355+
<div align="center"> <img src="../pics//0889c0b4-07b4-45fc-873c-e0e16b97f67d.png"/> </div><br>
23562356

23572357
### Implementation
23582358

16 KB
Loading
16 KB
Loading

0 commit comments

Comments
 (0)