recursion->memoization->tabulation (C++)
Please upvote if you liked the solution ;)\n\nRECURSION\n\nclass Solution {\npublic:\n    int solve(int ind,int target)\n    {\n        if(ind==1)\n          re
*Please upvote if you liked the solution ;)*\n\n**RECURSION**\n```\nclass Solution {\npublic:\n    int solve(int ind,int target)\n    {\n        if(ind==1)\n          return 1 ;\n        int notPick=solve(ind-1,target);\n        int pick=0;\n        if(target>=ind)\n          pick=ind*solve(ind,target-ind);\n        \n        return max(pick,notPick);\n    }\n\tint integerBreak(int n){\n\t\treturn solve(n-1,n);\n\t}\n}; \n```\n\n**MEMOIZATION**\n```\nclass Solution {\npublic:\n    int solve(int ind,int target,vector<vector<int>>&dp)\n    {\n        if(ind==1)\n          return 1 ;\n        if(dp[ind][target]!=-1)\n           return dp[ind][target];\n        int notPick=solve(ind-1,target,dp);\n        int pick=0;\n        if(target>=ind)\n          pick=ind*solve(ind,target-ind,dp);\n        \n        return dp[ind][target]=max(pick,notPick);\n    }\n\tint integerBreak(int n){\n        vector<vector<int>>dp(n,vector<int>(n+1,-1));\n\t\treturn solve(n-1,n,dp);\n\t}\n}; \n```\n\n**TABULATION**\n```\nclass Solution {\npublic:\n\tint integerBreak(int n){\n\t\t vector<vector<int>>dp(n,vector<int>(n+1,0));\n         for(int i=0;i<=n;i++)\n          dp[1][i]=1;\n\n         for(int ind=2;ind<n;ind++)\n         {\n             for(int target=0;target<=n;target++)\n             {\n              int notPick=dp[ind-1][target];\n              int pick=0;\n              if(target>=ind)\n                  pick=ind*dp[ind][target-ind];\n        \n               dp[ind][target]=max(pick,notPick);\n             }\n         }\n         return dp[n-1][n];\n\t}\n}; \n
['C++']