Integer Break Solutions in GoNumber 343Difficulty MediumAcceptance 50.4%Link LeetCodeOther languages C++, JavaSolutionsGo solution by halfrost/LeetCode-Gopackage leetcode func integerBreak(n int) int { dp := make([]int, n+1) dp[0], dp[1] = 1, 1 for i := 1; i <= n; i++ { for j := 1; j < i; j++ { // dp[i] = max(dp[i], j * (i - j), j*dp[i-j]) dp[i] = max(dp[i], j*max(dp[i-j], i-j)) } } return dp[n]} func max(a int, b int) int { if a > b { return a } return b}package leetcode func integerBreak(n int) int { dp := make([]int, n+1) dp[0], dp[1] = 1, 1 for i := 1; i <= n; i++ { for j := 1; j < i; j++ { // dp[i] = max(dp[i], j * (i - j), j*dp[i-j]) dp[i] = max(dp[i], j*max(dp[i-j], i-j)) } } return dp[n] } func max(a int, b int) int { if a > b { return a } return b }