Skip to content

Commit

Permalink
auto commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CyC2018 committed Oct 8, 2018
1 parent 5cdab85 commit 2a11c8f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
43 changes: 22 additions & 21 deletions notes/Leetcode 题解.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
```

## 二分查找

**正常实现**
Expand Down Expand Up @@ -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;
}
```

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

Expand Down
2 changes: 1 addition & 1 deletion notes/Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ dmtsai lines: 5 columns: 9
- 得到 SIGCHLD 信号;
- waitpid() 或者 wait() 调用会返回。

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

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

Expand Down
2 changes: 1 addition & 1 deletion notes/计算机操作系统.md
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ FIFO 常用于客户-服务器应用程序中,FIFO 用作汇聚点,在客户

主要有以下四种方法:

- 鸵鸟策略
- 鸵鸟策略
- 死锁检测与死锁恢复
- 死锁预防
- 死锁避免
Expand Down
2 changes: 1 addition & 1 deletion notes/设计模式.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added pics/0889c0b4-07b4-45fc-873c-e0e16b97f67d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/f8b3f73d-0fda-449f-b55b-fa36b7ac04cd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2a11c8f

Please sign in to comment.