Python Clean DP
dp[i,j] stands for the minimum insertion steps to make s[i:j+1] palindrome.\nIf s[i] == s[j] then dp[i,j] should be equal to dp[i+1,j-1] as no extra cost needed
`dp[i,j]` stands for the minimum insertion steps to make `s[i:j+1]` palindrome.\nIf `s[i] == s[j]` then `dp[i,j]` should be equal to `dp[i+1,j-1]` as no extra cost needed for a palidrome string to include `s[i]` on the left and `s[j]` on the right. \nOtherwise, `dp[i,j]` take an extra 1 cost from the smaller cost between `dp[i+1,j]` and `dp[i,j-1]`.\nThen the recurrence equation would be: \n`dp[i][j] = dp[i+1][j-1] if s[i] == s[j] else min(dp[i+1][j], dp[i][j-1]) + 1`\n\nTo build a bottom-up iteration, we need to iterate all the combination of `(i, j)` where `i < j`. \nThere is no need to check `dp[i,i]` which is `0`. \nAnother base case is `dp[i,i-1]`. This happens only when we are checking a `dp[i,i+1]` and `s[i] == s[i+1]`. This can also be set as `0` so `dp[i,i+1]` will be `0` correctly.\nSo we can savely initialized the entire `dp` array to be filled with `0`.\n```\ndef minInsertions(self, s):\n\tn = len(s)\n\tdp = [[0] * n for _ in range(n)]\n\tfor j in range(n):\n\t\tfor i in range(j-1,-1,-1):\n\t\t\tdp[i][j] = dp[i+1][j-1] if s[i] == s[j] else min(dp[i+1][j], dp[i][j-1]) + 1\n\treturn dp[0][n-1]\n```
['Python']