From 35154b7be3d47785f77ec3680b71f2201fb2e9c1 Mon Sep 17 00:00:00 2001 From: baici1 <249337001@qq.com> Date: Fri, 22 Oct 2021 16:58:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B9=B0=E5=8D=96=E8=82=A1?= =?UTF-8?q?=E7=A5=A8=E6=9C=80=E4=BD=B3=E6=97=B6=E6=9C=BA=E2=85=A1=EF=BC=8C?= =?UTF-8?q?=E4=B9=B0=E5=8D=96=E8=82=A1=E7=A5=A8=E6=9C=80=E4=BD=B3=E6=97=B6?= =?UTF-8?q?=E6=9C=BA=E2=85=A2=EF=BC=8C=E4=B9=B0=E5=8D=96=E8=82=A1=E7=A5=A8?= =?UTF-8?q?=E6=9C=80=E4=BD=B3=E6=97=B6=E6=9C=BA=E2=85=A3=20go=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...票的最佳时机II(动态规划).md | 25 +++++++++++++ .../0123.买卖股票的最佳时机III.md | 32 +++++++++++++++++ .../0188.买卖股票的最佳时机IV.md | 36 +++++++++++++++++++ 3 files changed, 93 insertions(+) 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: