C++||Picture Explanation🔥||Recursion-->Memoization 🔥|| With Recursion Tree🔥
Approach\n Describe your approach to solving the problem. \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Complexity\n- Time complexity: O(n^2
# Approach\n<!-- Describe your approach to solving the problem. -->\n\n![image.png](https://assets.leetcode.com/users/images/50813e57-3459-4f29-bf89-329fe7ac3052_1682127238.8847425.png)\n![image.png](https://assets.leetcode.com/users/images/86dae25f-8ad9-4864-9952-32908c088811_1682127258.409485.png)\n![image.png](https://assets.leetcode.com/users/images/90bb7033-267e-419e-b8f5-d6d45cb09a89_1682127283.5393384.png)\n![image.png](https://assets.leetcode.com/users/images/c657ad82-d3af-41fc-9090-d6478c115089_1682127360.4488578.png)\n![image.png](https://assets.leetcode.com/users/images/a1c0ef10-631c-46b9-963e-09936a95d850_1682127396.9829204.png)\n![image.png](https://assets.leetcode.com/users/images/21ab37ce-405d-4a27-9494-e78ff6dcb5b6_1682127416.34991.png)\n![image.png](https://assets.leetcode.com/users/images/44af89b1-f288-4584-a77b-1eccd76d104b_1682127463.1750078.png)\n![image.png](https://assets.leetcode.com/users/images/4bfde9fd-ab36-451b-bb6e-85db6b4b4dce_1682127485.4674213.png)\n![image.png](https://assets.leetcode.com/users/images/aa4158f3-775c-45b9-aa99-87a001a491b1_1682127508.6822114.png)\n![image.png](https://assets.leetcode.com/users/images/7e8df1ee-f397-4d07-89da-a40f1bd3497f_1682127529.1466532.png)\n![image.png](https://assets.leetcode.com/users/images/b8568aa7-594b-4b45-9b74-4066831d8f2b_1682127549.7029772.png)\n![image.png](https://assets.leetcode.com/users/images/4b06186f-2a25-4ab3-878c-20426fff9895_1682127775.0427327.png)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Complexity\n- Time complexity: O(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n^2)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nPlease UPVOTE if you liked the explanation.\n\n# BRUTE FORCE Code:\n```\nclass Solution {\npublic:\n    //BRUTE FORCE= RECURSION\n    int makePalindrome(int i, int j, string &s){\n        if(i>=j) return 0;\n        else if(s[i]==s[j]) return makePalindrome(i+1, j-1, s);\n        else{\n            int possibility1= makePalindrome(i+1, j, s);\n            int possibility2= makePalindrome(i, j-1, s);\n\n            return min(possibility1, possibility2)+1;\n        }\n    }\n    int minInsertions(string s) {\n        int n= s.size();\n        return makePalindrome(0, n-1, s);\n    }\n};\n```\n# Memoization Code:\n```\nclass Solution {\npublic:\n    int makePalindrome(int i, int j, string &s, vector<vector<int>>&dp){\n        if(i>=j) return 0;\n        else if(dp[i][j]!=-1) return dp[i][j];\n        else if(s[i]==s[j]) return makePalindrome(i+1, j-1, s, dp);\n        else{\n            int possibility1= makePalindrome(i+1, j, s, dp);\n            int possibility2= makePalindrome(i, j-1, s, dp);\n\n            dp[i][j]= min(possibility1, possibility2)+1;\n            return dp[i][j];\n        }\n    }\n    int minInsertions(string s) {\n        int n= s.size();\n        vector<vector<int>> dp(n, vector<int>(n,-1));\n        return makePalindrome(0, n-1, s, dp);\n    }\n};\n```
['Dynamic Programming', 'Recursion', 'C++']