Menu
  • Categories
  • Categories
  • Tags
  • Tags
  • About
    文章: 1607 | 分类: 33 | 标签: 165
    Table of contents
    1. 题目描述
    2. 思路分析
    3. 参考代码
    走在修行的大街上

    LeetCode 343. 整数拆分

    • Categories:
    • Tags:
    1. 题目描述
    2. 思路分析
    3. 参考代码

    题目描述

    ✅ 343. 整数拆分

    思路分析

    image-20250523184757683

    参考代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    func integerBreak(n int) int {
    	var dp = make([]int, n+1)
    	dp[0], dp[1] = 0, 0
    
    	for i := 2; i <= n; i++ {
    		for j := 1; j < i; j++ {
    			dp[i] = max(dp[i], max(j*(i-j), j*dp[i-j]))
    		}
    	}
    
    	return dp[n]
    }
    

    ➡️ 点击查看 Java 题解

    1
    
    write your code here
    

    上一篇
    下一篇
    本文作者: HGNULB
    本文链接: https://hgnulb.github.io/blog/2025/63992688
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处!
    About

    Copyright ©2017-2025 走在修行的大街上 All rights reserved

    本文阅读量   次 本站访问量   次 本站访客数   人