题目:

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
解题过程:
动态规划
解题思路来自LeetCode用户leetcode_xsong

class CQueue {
public int cuttingRope(int n) {
int[] dp = new int[n+1];
dp[2] = 1;
for(int i = 3; i < n+1; i++){
for(int j = 1; j <= i/2; j++){
dp[i] = Math.max(dp[i], Math.max(j * (i - j), j * dp[i-j]));
}
}
return dp[n];
}
作者:LeetCode_xsong
链接:https://leetcode-cn.com/problems/jian-sheng-zi-lcof/solution/jian-zhi-offer-by-leetcode_xsong-yrqo/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
执行结果:

该博客介绍了使用动态规划解决LeetCode中的一道题目——剪绳子,目标是找到最大化乘积的切割方法。博主leetcode_xsong分享了具体的解题代码,并通过动态规划数组dp实现了求解过程。
286

被折叠的 条评论
为什么被折叠?



