📌📌 C++ || DP || Memo || Faster || Easy To Understand 🤷‍♂️🤷‍♂️
Memo\n\n Time Complexity :- O(N * N)\n\n Space Complexity :- O(N * N)\n\n\nclass Solution {\npublic:\n    \n    // declare a 2D dp array\n    \n    vector<vecto
* ***Memo***\n\n* ***Time Complexity :- O(N * N)***\n\n* ***Space Complexity :- O(N * N)***\n\n```\nclass Solution {\npublic:\n    \n    // declare a 2D dp array\n    \n    vector<vector<int>> dp;\n    \n    int helper(string &str, int low, int high)\n    {\n        // base case\n        \n        if(low >= high)\n            return 0;\n        \n        // if already calculated\n        \n        if(dp[low][high] != -1)\n            return dp[low][high];\n        \n        if(str[low] == str[high])\n            return dp[low][high] = helper(str, low + 1, high - 1);\n        else\n        {\n            return dp[low][high] = 1 + min(helper(str, low + 1, high), helper(str, low, high - 1));\n        }\n        \n    }\n    \n    int minInsertions(string str) {\n        \n        int n = str.size();\n        \n        int low = 0;\n        \n        int high = n - 1;\n        \n        // resize dp\n        \n        dp.resize(n + 1);\n        \n        // initialize dp\n        \n        dp.assign(n + 1, vector<int> (n + 1, -1));\n        \n        // call helper function\n        \n        return helper(str, low, high);\n    }\n};\n```
['Dynamic Programming', 'Memoization', 'C', 'C++']