Integer Break
Medium · Math, Dynamic Programming
Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers.
Return the maximum product you can get.
Example 1
Input: n = 2 Output: 1
2 = 1 + 1, 1 × 1 = 1.
Example 2
Input: n = 10 Output: 36
10 = 3 + 3 + 4, 3 × 3 × 4 = 36.
Constraints
- 2 <= n <= 58
Starter code (python)
class Solution(object):
def integerBreak(self, n):
"""
:type n: int
:rtype: int
"""
Related problems
- Add Two Numbers (Medium)
- Longest Palindromic Substring (Medium)
- Reverse Integer (Medium)
Previous: Power of Four · Next: Reverse Vowels of a String · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.