class Solution { /** To make a string a palindrome with minimum insertions, we try to keep the largest palindromic part of the string unchanged and insert characters for the rest. Minimum Insertions=n−LPS length Minimum Deletion=n−LPS length 1. Reverse the string and store it in new string 2. Find Longest Common Subsequence (LCS) between s and reverse(s). 3. That LCS is the Longest Palindromic Subsequence. */ public int minInsertions(String s) { String s2 = new StringBuilder(s).reverse().toString(); int n = s.length(); int m = s2.length(); // create a matrix int[][] t = new int[n+1][m+1]; // initialise the matrix for(int i=0; i