JAVA Top Down DP Intution Solution
Basic Intution : maximum product  can be achieved in two cases \n\t\t\t\t\t\t\t\t1) for each i till n we calculate i (n-i) and take max of it\n\t\t\t\t\t\t\t\t2
**Basic Intution** : maximum product  can be achieved in two cases \n\t\t\t\t\t\t\t\t1) for each i till n we calculate i *(n-i) and take max of it\n\t\t\t\t\t\t\t\t2)  for each i till n we calculate i* recursion of (n-i)  and take max of it. \nWe use dp to store repetitive subproblems\n\tdp[i] represents max product we can achieve breaking the sum i\n\tNote: it necessarily doesn\'t need to i*subproblem(n-i) for ans to be max the answer can be maximum in cases where i*(n-1)\n\tEg: 5\n\t\tCase1: n=5 i=2\n\t\t\t3+2=5 \n\t\t\t3x2=6\n\t\tCase 2: n=5 i=2\n\t\t\t2*memo(3,dp)=2*2=4;\n\t\tans=max(case1,case2);\n```\nclass Solution {\n    public int memo(int n,int[] dp){\n        if(dp[n]!=-1){\n            return dp[n];\n        }\n        int max=0;\n        for(int i=1;i<n;i++){\n            max=Math.max(max,Math.max(i*(n-i),i*memo(n-i,dp)));\n        }\n        return dp[n]=max;\n    }\n    public int integerBreak(int n) {\n        int dp[]=new int[n+1];\n        Arrays.fill(dp,-1);\n        dp[0]=0;\n        dp[1]=1;\n        memo(n,dp);\n            // System.out.print(dp[i]+" ");\n        return dp[n];\n    }\n}\n```\nI hope the intution makes it clear .\nPlease upvote if it helps :)
['Dynamic Programming', 'Java']