diff --git a/problems/0122.买卖股票的最佳时机II(动态规划).md b/problems/0122.买卖股票的最佳时机II(动态规划).md index 4e64beaf..30c56c25 100644 --- a/problems/0122.买卖股票的最佳时机II(动态规划).md +++ b/problems/0122.买卖股票的最佳时机II(动态规划).md @@ -200,6 +200,31 @@ class Solution: Go: +```go +func maxProfit(prices []int) int { + //创建数组 + dp:=make([][]int,len(prices)) + for i:=0;ib{ + return a + } + return b +} +``` + + + JavaScript: > 版本一: diff --git a/problems/0188.买卖股票的最佳时机IV.md b/problems/0188.买卖股票的最佳时机IV.md index 5cffbe9e..a97f293a 100644 --- a/problems/0188.买卖股票的最佳时机IV.md +++ b/problems/0188.买卖股票的最佳时机IV.md @@ -276,6 +276,42 @@ class Solution: ``` Go: +```go +func maxProfit(k int, prices []int) int { + if len(prices)==0{ + return 0 + } + dp:=make([][]int,len(prices)) + for i:=0;ib{ + return a + } + return b +} +``` + + + Javascript: