15% off all plans & roadmaps Use code
See plansProblem editorial
Given the integer n, split it into the sum of at least two positive integers. The parts may be equal, and their order does not affect the result. The product of a split is the multiplication of all its parts.
Integer Break is a Dynamic Programming (DP) Patterns problem, in the 1D Array (Fibonacci Style) subpattern. The pattern covers fibonacci, Kadane, knapsack, LCS, LIS, edit distance, grid paths, and word break
The reference solution runs in O(n^2) time and O(n) space.
The full editorial is part of Pro
It explains the core insight, the complexity analysis and the common mistakes, with a worked solution.
Integer Break is a Dynamic Programming (DP) Patterns problem, in the 1D Array (Fibonacci Style) subpattern. Once the approach above makes sense, write it yourself and then work through the neighbouring problems that reuse it.