JAVA | SIMPLE EXPLANATION | CODE WITH DETAILED COMMENTS
Simple explanation https://www.youtube.com/watch?v=IWV3wolx13k\n\nAbove video explains Recursion and Top-Down DP approach. Part 2 of the video will have Bottom 
Simple explanation https://www.youtube.com/watch?v=IWV3wolx13k\n\nAbove video explains Recursion and Top-Down DP approach. Part 2 of the video will have Bottom up approach as well\n\nFor more:-\n**Telegram group** - https://t.me/+IK5-RpKtVWUxMDI1\n**Telegram channel** - https://t.me/betterSoftEng\n\n```\nclass FormAPalindromeSolution{\n    static int countMin(String str)\n    {\n        // code here\n        int n = str.length();\n\n        //Each element of the matrix stores the result for substring from i to j\n        int[][] matrix = new int[n][n];\n\n        //Gap indicates the length of the string for which we are filling the matrix\n        //currently\n        int gap;\n\n        //First we fill size 1 substrings\n        //Then we fill size 2 substrings and so on.\n        for(gap = 1; gap<=n; gap++) {\n            fillMatrix(matrix, gap, str);\n        }\n\n        return matrix[0][n-1];\n    }\n\n    private static void fillMatrix(int[][] matrix, int gap, String s) {\n\n        int n = s.length();\n        //To iterate over string to get a starting position\n        int i;\n        // j tracks end position\n        int j;\n        //If gap = 1 => all 1-length strings are already palindromes.\n\n        int resultLeft;\n        int resultRight;\n        int resultMid;\n\n        //For gap 1, i and j are same\n        if(gap == 1) {\n            for(i=0; i<=n-1; i++) {\n                j = i;\n                matrix[i][j] = 0;\n            }\n        }\n\n        if(gap == 2) {\n            //Starting position shouldn\'t reach last character\n            for(i=0; i<n-1; i++) {\n                //Since length = 2 => j = i+1\n                j = i+1;\n                if(s.charAt(i) == s.charAt(j)) {\n                    matrix[i][j] = 0;\n                } else {\n                    matrix[i][j] = 1;\n                }\n            }\n        }\n        for(gap=3; gap<=n; gap++) {\n            //Loop till Starting position i can reach\n            for(i=0; i<=n-gap; i++) {\n                //Calculate end position wrt i\n                j = i+gap-1;\n                //The result for substring except last character + 1\n                resultLeft = matrix[i][j-1] + 1;\n                // The result for substring except first character + 1\n                resultRight = matrix[i+1][j] + 1;\n\n                if(s.charAt(i) == s.charAt(j)) {\n                    //The result if first and last character are same, then\n                    //how many insertions does it take to make the middle string\n                    //palindrome\n                    resultMid = matrix[i+1][j-1];\n                    //Minimum of all 3\n                    matrix[i][j] = Math.min(resultMid, Math.min(resultLeft, resultRight));\n                } else {\n                    matrix[i][j] = Math.min(resultLeft, resultRight);\n                }\n            }\n        }\n    }\n}\n```
['Dynamic Programming', 'Java']