Java Similar to Unbounded Knapsack (Brute Force, Recursion With Memoization, 2D Dynamic Programming)
Method 1 : Brute Force\nTime   Complexity : O(2^n)\nSpace Complexity : O(n)\n\nclass Solution {\n    public int integerBreak(int n) {\n        return unboundedK
Method 1 : Brute Force\nTime   Complexity : O(2^n)\nSpace Complexity : O(n)\n```\nclass Solution {\n    public int integerBreak(int n) {\n        return unboundedKnapsack(n, n-1);\n    }\n    public int unboundedKnapsack(int n, int curr) {\n        if(n<0 || curr < 0)\n            return 0;\n        if(n == 0)\n            return 1;\n        if(curr == 0)\n            return 0;\n        if(n< curr)\n            return unboundedKnapsack(n, curr-1);\n        else \n            return Math.max(unboundedKnapsack(n, curr-1), curr*unboundedKnapsack(n-curr, curr));    \n    }\n}\n```\n\nMethod 2 : Recursion With Memoization\nTime   Complexity : O(n * n)\nSpace Complexity : O(n * n)\n```\nclass Solution {\n    public int integerBreak(int n) {\n        Integer [][] dp = new Integer[n+1][n+1];\n        return unboundedKnapsack(n, n-1, dp);\n    }\n    public int unboundedKnapsack(int n, int curr, Integer [][] dp) {\n        if(dp[n][curr] != null)\n            return dp[n][curr];\n        if(n<0 || curr < 0)\n            return 0;\n        if(n == 0)\n            return dp[n][curr] = 1;\n        if(curr == 0)\n            return dp[n][curr] = 0; \n        if(n< curr) \n            return dp[n][curr] = unboundedKnapsack(n, curr-1, dp);\n        else \n            return dp[n][curr] = Math.max(unboundedKnapsack(n, curr-1, dp), curr*unboundedKnapsack(n-curr, curr, dp));    \n    }\n}\n```\n\nMethod 3 : 2D Dynamic Programming \nTime   Complexity : O(n * n)\nSpace Complexity : O(n * n)\n```\nclass Solution {\n    public int integerBreak(int n) {\n        if (n == 2)\n            return 1;\n        if (n == 3)\n            return 2;\n        int [][] dp = new int[n+1][n+1];\n        for(int i=0;i<dp.length;i++)\n            dp[i][0] = 0;\n        for(int j=0;j<dp[0].length;j++)\n            dp[0][j] = 1;\n        for(int i=1;i<dp.length;i++) {\n            for(int j=1;j<dp[0].length;j++) {\n                if(i<j) \n                    dp[i][j] = dp[i][j-1];\n                else \n                    dp[i][j] = Math.max(dp[i][j-1], j*dp[i-j][j]);\n            }\n        }\n        return dp[n][n];\n    } \n}\n```\n
[]