Rust, DP, short and concise solution ✅🔔🚩
Intuition\nSimple dynamic programming approach. The subtask is to solve it for substring of length j starting with index i.\ndp[i][j] - the number of insersions
# Intuition\nSimple dynamic programming approach. The subtask is to solve it for substring of length `j` starting with index `i`.\n`dp[i][j]` - the number of insersions to make palindrome from substring `s[i..=i+j]`.\nEvery time you add one more character to substring you check if it\'s the same as first character, if so, `dp[i][j] = dp[i - 2][j]`, otherwise, to make it palindrome you need to make one insersion to the beginning or the end, so `dp[i][j] = min(dp[i - 1][j], dp[i - 1][j + 1]) + 1`.\n\n# Code\n```\nuse std::cmp::min;\n\nimpl Solution {\n    pub fn min_insertions(s: String) -> i32 {\n        let chars: Vec<char> = s.chars().collect();\n        let mut dp = vec![vec![0; chars.len()]; chars.len() + 1];\n        for i in 2..chars.len() + 1 {\n            for j in 0..chars.len() - i + 1 {\n                if chars[j] == chars[j + i - 1] {\n                    dp[i][j] = dp[i - 2][j + 1];\n                } else {\n                    dp[i][j] = min(dp[i - 1][j], dp[i - 1][j + 1]) + 1;\n                }\n            }\n        }\n\n        return dp[chars.len()][0];\n    }\n}\n```
['Rust']