From 3f45f392f6c0235393171494790b43eea6350e30 Mon Sep 17 00:00:00 2001 From: X-shuffle <53906918+X-shuffle@users.noreply.github.com> Date: Tue, 17 Aug 2021 20:00:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=200343.=E6=95=B4=E6=95=B0?= =?UTF-8?q?=E6=8B=86=E5=88=86=20go=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0343.整数拆分.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/problems/0343.整数拆分.md b/problems/0343.整数拆分.md index a9c55a85..03b6f0fc 100644 --- a/problems/0343.整数拆分.md +++ b/problems/0343.整数拆分.md @@ -227,7 +227,34 @@ class Solution: return dp[n] ``` Go: - +```golang +func integerBreak(n int) int { + /** + 动态五部曲 + 1.确定dp下标及其含义 + 2.确定递推公式 + 3.确定dp初始化 + 4.确定遍历顺序 + 5.打印dp + **/ + dp:=make([]int,n+1) + dp[1]=1 + dp[2]=1 + for i:=3;ib{ + return a + } + return b +} +``` Javascript: ```Javascript