mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2026-02-02 18:39:09 +08:00
更新 买卖股票的最佳时机系列 排版格式修复
This commit is contained in:
@@ -31,9 +31,9 @@
|
||||
* 0 <= prices.length <= 1000
|
||||
* 0 <= prices[i] <= 1000
|
||||
|
||||
# 算法公开课
|
||||
## 算法公开课
|
||||
|
||||
**《代码随想录》算法视频公开课:[动态规划来决定最佳时机,至多可以买卖K次!| LeetCode:188.买卖股票最佳时机4](https://www.bilibili.com/video/BV16M411U7XJ),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
||||
**[《代码随想录》算法视频公开课](https://programmercarl.com/other/gongkaike.html):[动态规划来决定最佳时机,至多可以买卖K次!| LeetCode:188.买卖股票最佳时机4](https://www.bilibili.com/video/BV16M411U7XJ),相信结合视频再看本篇题解,更有助于大家对本题的理解**。
|
||||
|
||||
|
||||
## 思路
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
|
||||
## 其他语言版本
|
||||
|
||||
Java:
|
||||
### Java:
|
||||
|
||||
```java
|
||||
// 版本一: 三维 dp数组
|
||||
@@ -295,7 +295,7 @@ class Solution {
|
||||
}
|
||||
```
|
||||
|
||||
Python:
|
||||
### Python:
|
||||
|
||||
版本一
|
||||
|
||||
@@ -329,7 +329,7 @@ class Solution:
|
||||
dp[j] = max(dp[j],dp[j-1]+prices[i])
|
||||
return dp[2*k]
|
||||
```
|
||||
Go:
|
||||
### Go:
|
||||
|
||||
版本一:
|
||||
|
||||
@@ -404,7 +404,7 @@ func max188(a, b int) int {
|
||||
}
|
||||
```
|
||||
|
||||
Javascript:
|
||||
### JavaScript:
|
||||
|
||||
```javascript
|
||||
// 方法一:动态规划
|
||||
@@ -454,7 +454,7 @@ var maxProfit = function(k, prices) {
|
||||
};
|
||||
```
|
||||
|
||||
TypeScript:
|
||||
### TypeScript:
|
||||
|
||||
```typescript
|
||||
function maxProfit(k: number, prices: number[]): number {
|
||||
@@ -474,7 +474,7 @@ function maxProfit(k: number, prices: number[]): number {
|
||||
};
|
||||
```
|
||||
|
||||
Rust:
|
||||
### Rust:
|
||||
|
||||
```rust
|
||||
impl Solution {
|
||||
@@ -529,3 +529,4 @@ 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