auto commit

This commit is contained in:
CyC2018
2021-03-23 02:48:19 +08:00
parent 6027156d73
commit 156f7a67f4
15 changed files with 98 additions and 70 deletions

View File

@ -2,7 +2,7 @@
## 题目链接
[Leetcode](https://leetcode.com/problems/integer-break/description/)
[牛客网](https://www.nowcoder.com/practice/57d85990ba5b440ab888fc72b0751bf8?tpId=13&tqId=33257&tab=answerKey&from=cyc_github)
## 题目描述
@ -37,7 +37,7 @@ return 36 (10 = 3 + 3 + 4)
继续拆成更大的绳子可以发现都比拆成 2 3 的效果更差因此我们只考虑将绳子拆成 2 3并且优先拆成 3当拆到绳子长度 n 等于 4 也就是出现 3+1此时只能拆成 2+2
```java
public int integerBreak(int n) {
public int cutRope(int n) {
if (n < 2)
return 0;
if (n == 2)
@ -55,7 +55,7 @@ public int integerBreak(int n) {
### 动态规划
```java
public int integerBreak(int n) {
public int cutRope(int n) {
int[] dp = new int[n + 1];
dp[1] = 1;
for (int i = 2; i <= n; i++)