1312. Minimum Insertion Steps to Make a String Palindrome Hard
1/**
2 * [1312] Minimum Insertion Steps to Make a String Palindrome
3 *
4 * Given a string s. In one step you can insert any character at any index of the string.
5 * Return the minimum number of steps to make s palindrome.
6 * A Palindrome String is one that reads the same backward as well as forward.
7 *
8 * Example 1:
9 *
10 * Input: s = "zzazz"
11 * Output: 0
12 * Explanation: The string "zzazz" is already palindrome we don't need any insertions.
13 *
14 * Example 2:
15 *
16 * Input: s = "mbadm"
17 * Output: 2
18 * Explanation: String can be "mbdadbm" or "mdbabdm".
19 *
20 * Example 3:
21 *
22 * Input: s = "leetcode"
23 * Output: 5
24 * Explanation: Inserting 5 characters the string becomes "leetcodocteel".
25 *
26 *
27 * Constraints:
28 *
29 * 1 <= s.length <= 500
30 * s consists of lowercase English letters.
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/
36// discuss: https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn min_insertions(s: String) -> i32 {
42 0
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1312() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.