> For the complete documentation index, see [llms.txt](https://ucan.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ucan.gitbook.io/notes/dynamic-programming/343.-integer-break.md).

# 343. Integer Break

{% hint style="info" %}
dp\[i]=Math.max(dp\[i], j\*Math.max(i-j,dp\[i-j]));
{% endhint %}

```java
class Solution {
    public int integerBreak(int n) {
        // value at index i refer to the ans of number i;
        int[] memo = new int[n+1];
        memo[1]=1;
        for (int i=2; i<=n; i++){
            for (int j = 1; j<=i/2; j++){
                // compare i-j with memo[i-j];
                memo[i]=Math.max(memo[i], j*Math.max(i-j, memo[i-j]));
            }
        }
        
        return memo[n];
    }
}
```
