From 759f05328dfabb652a034b6400d2a162edc91679 Mon Sep 17 00:00:00 2001 From: fusunx <1102654482@qq.com> Date: Fri, 2 Jul 2021 07:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E6=95=B0=E6=8B=86=E5=88=86.md=20Javas?= =?UTF-8?q?cript?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 16 ---------------- problems/0343.整数拆分.md | 13 +++++++++++++ 2 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 2ca27187..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - // 使用 IntelliSense 了解相关属性。 - // 悬停以查看现有属性的描述。 - // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - - { - "type": "pwa-chrome", - "request": "launch", - "name": "Launch Chrome against localhost", - "url": "http://localhost:8080", - "webRoot": "${workspaceFolder}" - } - ] -} \ No newline at end of file diff --git a/problems/0343.整数拆分.md b/problems/0343.整数拆分.md index cf60575f..7b0dbd0f 100644 --- a/problems/0343.整数拆分.md +++ b/problems/0343.整数拆分.md @@ -225,7 +225,20 @@ class Solution: Go: +Javascript: +```Javascript +var integerBreak = function(n) { + let dp = new Array(n + 1).fill(0) + dp[2] = 1 + for(let i = 3; i <= n; i++) { + for(let j = 1; j < i; j++) { + dp[i] = Math.max(dp[i], dp[i - j] * j, (i - j) * j) + } + } + return dp[n] +}; +``` ----------------------- * 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)