Minimum insertions for palindrome

Write codeHard35 min

Your task

Return the minimum number of characters you must insert anywhere into s to make it a palindrome. For example "mbadm" needs 2 insertions (one valid result is "mdbabdm"), while "zzazz" is already a palindrome and needs 0. The empty string and single characters need 0. Strings can be up to ~1000 characters; an O(n^2) DP is expected.

Examples

min_insertions_palindrome(s: str) -> int
Example 1
Inputmin_insertions_palindrome("mbadm")
Output2