mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
更新 买卖股票的最佳时机系列 排版格式修复
This commit is contained in:
@@ -34,9 +34,9 @@
|
||||
* 1 <= prices.length <= 3 * 10 ^ 4
|
||||
* 0 <= prices[i] <= 10 ^ 4
|
||||
|
||||
# 算法公开课
|
||||
## 算法公开课
|
||||
|
||||
**《代码随想录》算法视频公开课:[动态规划,股票问题第二弹 | LeetCode:122.买卖股票的最佳时机II](https://www.bilibili.com/video/BV1D24y1Q7Ls),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
||||
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划,股票问题第二弹 | LeetCode:122.买卖股票的最佳时机II](https://www.bilibili.com/video/BV1D24y1Q7Ls),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
||||
|
||||
|
||||
## 思路
|
||||
@@ -133,8 +133,8 @@ public:
|
||||
|
||||
## 其他语言版本
|
||||
|
||||
### Java:
|
||||
|
||||
Java:
|
||||
```java
|
||||
// 动态规划
|
||||
class Solution
|
||||
@@ -191,7 +191,7 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Python:
|
||||
### Python:
|
||||
|
||||
> 版本一:
|
||||
```python
|
||||
@@ -221,7 +221,8 @@ class Solution:
|
||||
return dp[(length-1) % 2][1]
|
||||
```
|
||||
|
||||
Go:
|
||||
### Go:
|
||||
|
||||
```go
|
||||
// 买卖股票的最佳时机Ⅱ 动态规划
|
||||
// 时间复杂度:O(n) 空间复杂度:O(n)
|
||||
@@ -250,7 +251,8 @@ func max(a, b int) int {
|
||||
}
|
||||
```
|
||||
|
||||
Javascript:
|
||||
### JavaScript:
|
||||
|
||||
```javascript
|
||||
// 方法一:动态规划(dp 数组)
|
||||
const maxProfit = (prices) => {
|
||||
@@ -290,7 +292,7 @@ const maxProfit = (prices) => {
|
||||
}
|
||||
```
|
||||
|
||||
TypeScript:
|
||||
### TypeScript:
|
||||
|
||||
> 动态规划
|
||||
|
||||
@@ -326,7 +328,7 @@ function maxProfit(prices: number[]): number {
|
||||
};
|
||||
```
|
||||
|
||||
C#:
|
||||
### C#:
|
||||
|
||||
> 贪心法
|
||||
|
||||
@@ -363,7 +365,7 @@ public class Solution
|
||||
}
|
||||
```
|
||||
|
||||
Rust:
|
||||
### Rust:
|
||||
|
||||
> 贪心
|
||||
|
||||
@@ -414,4 +416,3 @@ impl Solution {
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user