Math, C++, 100% faster
class Solution {\npublic:\n    \n    // it is always optimal to split the number in form 2x+3y  if n>5\n    // example - 8 as 3+3+2, 10 as 3+3+2+2\n    // Proof
class Solution {\npublic:\n    \n    // it is always optimal to split the number in form 2x+3y  if n>5\n    // example - 8 as 3+3+2, 10 as 3+3+2+2\n    // Proof intuition\n    // Say number is of form 6+x, now product is 6*x but if we make it as 3+3+x its product is 9*x\n    // also its better to split it into more threes than two as 3*(x-3) >= 2*(x-2) for x>=5\n    // now we are left if three cases :\n    // n%3 == 0 split it as n/3 3\'s\n    // n%3 == 1 split it as (n/3 -1) 3\'s and two 2\'s\n    // n%3 == 2 split it as n/3  3\'s and one two\n    // can be done in O(logn) with binary exponentiation\n    \n    int binexp(int a,int b){\n        if(b == 0) return 1;\n        int res = binexp(a,b/2);\n        if(b%2 == 0) return (res*res);\n        return (a*res*res);\n    }\n    \n    \n    int integerBreak(int n) {\n        // handle 2 to 5 separately\n        if(n == 2) return 1;\n        if(n == 3) return 2;\n        if(n == 4) return 4;\n        if(n == 5) return 6;\n        \n        if(n%3 == 0){\n            return binexp(3,n/3);\n        }\n        if(n%3 == 1){\n            return binexp(3,n/3 -1)*4;\n        }\n        if(n%3 == 2){\n            return binexp(3,n/3)*2;\n        }\n        return 1;\n    }\n};``
[]