Java DFS with memoization similar to 1216. Valid Palindrome III
java\nclass Solution {\n    public int minInsertions(String s) {\n        if (s == null || s.length() == 0) return 0;\n        int[][] min = new int[s.length()]
```java\nclass Solution {\n    public int minInsertions(String s) {\n        if (s == null || s.length() == 0) return 0;\n        int[][] min = new int[s.length()][s.length()];\n        for (int[] row : min) Arrays.fill(row, -1);\n        return dp(s, 0, s.length() - 1, min);\n    }\n    private int dp(String s, int l, int r, int[][] min) {\n        if (l >= r) return 0;\n        if (min[l][r] >= 0) return min[l][r];\n        min[l][r] = s.charAt(l) == s.charAt(r) ? dp(s, l + 1, r - 1, min) : Math.min(dp(s, l + 1, r, min), dp(s, l, r - 1, min)) + 1;\n        return min[l][r];\n    }\n}\n```
['Depth-First Search', 'Memoization', 'Java']