Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.
Example
Input: 10
Output: 36
Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36.
Solution
class Solution:
def integerBreak(self, n: int) -> int:
case = [0,0,1,2,4,6,9]
if n<7:
return case[n]
dp = case + [0]*(n-6)
for i in range(7, n+1):
dp[i] = 3*dp[i-3]
return dp[-1]