C++ dynamic programming solution
class Solution {\n    public:\n        int integerBreak(int n) {\n            \n            if (n <= 2)\n                return 1;\n\n            vector<int> ma
    class Solution {\n    public:\n        int integerBreak(int n) {\n            \n            if (n <= 2)\n                return 1;\n\n            vector<int> maxArr(n+1, 0);\n                        \n            /** For a number i: write i as a sum of integers, then take the product of those integers.\n            maxArr[i] = maximum of all the possible products */\n            \n            maxArr[1] = 0;\n            maxArr[2] = 1; // 2=1+1 so maxArr[2] = 1*1\n            \n            for (int i=3; i<=n; i++) {\n                for (int j=1; j<i; j++) {\n                    /** Try to write i as: i = j + S where S=i-j corresponds to either one number or a sum of two or more numbers\n                    \n                    Assuming that j+S corresponds to the optimal solution for maxArr[i], we have two cases:\n                    (1) i is the sum of two numbers, i.e. S=i-j is one number, and so maxArr[i]=j*(i-j)\n                    (2) i is the sum of at least three numbers, i.e. S=i-j is a sum of at least 2 numbers,\n                    and so the product of the numbers in this sum for S is maxArr[i-j]\n                    (=maximum product after breaking up i-j into a sum of at least two integers):\n                    maxArr[i] = j*maxArr[i-j]\n                    */\n                    maxArr[i] = max(maxArr[i], max(j*(i-j), j*maxArr[i-j]));\n                }\n            }\n            return maxArr[n];\n        }\n    };
['Dynamic Programming', 'C++']