[ faster than 100.00%][memoization][dp][c++]
\n//memo [Runtime: 0 ms, faster than 100.00%]\nclass Solution {\npublic:\n    int integerBreak(int n,int *dp) {\n        if(n==0 || n==1)\n            return 1;
```\n//memo [Runtime: 0 ms, faster than 100.00%]\nclass Solution {\npublic:\n    int integerBreak(int n,int *dp) {\n        if(n==0 || n==1)\n            return 1;\n        \n        if(dp[n]!=-1) \n            return dp[n];\n        \n        int maxi=0;\n        \n        for(int i=1;i<n;i++){\n            maxi=max(maxi,max(integerBreak(n-i,dp)*i,i*(n-i)));\n        }\n        \n        return dp[n]=maxi;\n    }\n    int integerBreak(int n) {\n        int *ans = new int[n+1];\n\t\tfor(int j = 0; j <= n; j++) {\n\t\t\tans[j] = -1;\n\t\t}\n        return integerBreak(n,ans);\n    }\n};\n```\n\n```\n//dp [Runtime: 0 ms, faster than 100.00%]\nclass Solution {\npublic:\n    int integerBreak(int n) {\n        int dp[n+1];\n        dp[0]=1;\n        dp[1]=1;\n        for(int j=2;j<n+1;j++){\n            int maxi=0;\n            for(int i=1;i<j;i++){\n                maxi=max(maxi,max(dp[j-i]*i,i*(j-i)));\n            }\n            dp[j]=maxi;\n        }\n        return dp[n];\n    }\n};\n```\n**Feel free to ask any question in the comment section**.\nI hope that you\'ve found the solution useful.\nIn that case, **please do upvote and encourage me** to on my quest to document all leetcode problems\uD83D\uDE03\nHappy Coding :)\n
['Dynamic Programming', 'Recursion', 'Memoization', 'C', 'C++']