auto commit
This commit is contained in:
parent
5cdab85953
commit
2a11c8f396
|
@ -828,6 +828,28 @@ public int maxSubArray(int[] nums) {
|
|||
}
|
||||
```
|
||||
|
||||
**买入和售出股票最大的收益**
|
||||
|
||||
[121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
|
||||
|
||||
题目描述:只进行一次交易。
|
||||
|
||||
只要记录前面的最小价格,将这个最小价格作为买入价格,然后将当前的价格作为售出价格,查看当前收益是不是最大收益。
|
||||
|
||||
```java
|
||||
public int maxProfit(int[] prices) {
|
||||
int n = prices.length;
|
||||
if (n == 0) return 0;
|
||||
int soFarMin = prices[0];
|
||||
int max = 0;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (soFarMin > prices[i]) soFarMin = prices[i];
|
||||
else max = Math.max(max, prices[i] - soFarMin);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
```
|
||||
|
||||
## 二分查找
|
||||
|
||||
**正常实现**
|
||||
|
@ -3340,27 +3362,6 @@ public int maxProfit(int[] prices, int fee) {
|
|||
}
|
||||
```
|
||||
|
||||
**买入和售出股票最大的收益**
|
||||
|
||||
[121. Best Time to Buy and Sell Stock (Easy)](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/)
|
||||
|
||||
题目描述:只进行一次交易。
|
||||
|
||||
只要记录前面的最小价格,将这个最小价格作为买入价格,然后将当前的价格作为售出价格,查看当前收益是不是最大收益。
|
||||
|
||||
```java
|
||||
public int maxProfit(int[] prices) {
|
||||
int n = prices.length;
|
||||
if (n == 0) return 0;
|
||||
int soFarMin = prices[0];
|
||||
int max = 0;
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (soFarMin > prices[i]) soFarMin = prices[i];
|
||||
else max = Math.max(max, prices[i] - soFarMin);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
```
|
||||
|
||||
**只能进行两次的股票交易**
|
||||
|
||||
|
|
|
@ -1177,7 +1177,7 @@ dmtsai lines: 5 columns: 9
|
|||
- 得到 SIGCHLD 信号;
|
||||
- waitpid() 或者 wait() 调用会返回。
|
||||
|
||||
其中子进程发送的 SIGCHLD 信号包含了子进程的信息,包含了进程 ID、进程状态、进程使用 CPU 的时间等。
|
||||
其中子进程发送的 SIGCHLD 信号包含了子进程的信息,比如进程 ID、进程状态、进程使用 CPU 的时间等。
|
||||
|
||||
在子进程退出时,它的进程描述符不会立即释放,这是为了让父进程得到子进程信息,父进程通过 wait() 和 waitpid() 来获得一个已经退出的子进程的信息。
|
||||
|
||||
|
|
|
@ -719,7 +719,7 @@ FIFO 常用于客户-服务器应用程序中,FIFO 用作汇聚点,在客户
|
|||
|
||||
主要有以下四种方法:
|
||||
|
||||
- 鸵鸟策略;
|
||||
- 鸵鸟策略
|
||||
- 死锁检测与死锁恢复
|
||||
- 死锁预防
|
||||
- 死锁避免
|
||||
|
|
|
@ -2352,7 +2352,7 @@ public class Client {
|
|||
|
||||
### Class Diagram
|
||||
|
||||
<div align="center"> <img src="../pics//0f754c1d-b5cb-48cd-90e0-4a86034290a1.png"/> </div><br>
|
||||
<div align="center"> <img src="../pics//0889c0b4-07b4-45fc-873c-e0e16b97f67d.png"/> </div><br>
|
||||
|
||||
### Implementation
|
||||
|
||||
|
|
BIN
pics/0889c0b4-07b4-45fc-873c-e0e16b97f67d.png
Normal file
BIN
pics/0889c0b4-07b4-45fc-873c-e0e16b97f67d.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
pics/f8b3f73d-0fda-449f-b55b-fa36b7ac04cd.png
Normal file
BIN
pics/f8b3f73d-0fda-449f-b55b-fa36b7ac04cd.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user