2697. Lexicographically Smallest Palindrome Easy
1/**
2 * [2697] Lexicographically Smallest Palindrome
3 *
4 * You are given a string <code node="[object Object]">s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a character in <code node="[object Object]">s with another lowercase English letter.
5 * Your task is to make <code node="[object Object]">s a palindrome with the minimum number of operations possible. If there are multiple palindromes that can be <meta charset="utf-8" />made using the minimum number of operations, <meta charset="utf-8" />make the lexicographically smallest one.
6 * A string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.
7 * Return the resulting palindrome string.
8 *
9 * <strong class="example">Example 1:
10 *
11 * Input: s = "egcfe"
12 * Output: "efcfe"
13 * Explanation: The minimum number of operations to make "egcfe" a palindrome is 1, and the lexicographically smallest palindrome string we can get by modifying one character is "efcfe", by changing 'g'.
14 *
15 * <strong class="example">Example 2:
16 *
17 * Input: s = "abcd"
18 * Output: "abba"
19 * Explanation: The minimum number of operations to make "abcd" a palindrome is 2, and the lexicographically smallest palindrome string we can get by modifying two characters is "abba".
20 *
21 * <strong class="example">Example 3:
22 *
23 * Input: s = "seven"
24 * Output: "neven"
25 * Explanation: The minimum number of operations to make "seven" a palindrome is 1, and the lexicographically smallest palindrome string we can get by modifying one character is "neven".
26 *
27 *
28 * Constraints:
29 *
30 * 1 <= s.length <= 1000
31 * s consists of only lowercase English letters.
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/lexicographically-smallest-palindrome/
37// discuss: https://leetcode.com/problems/lexicographically-smallest-palindrome/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn make_smallest_palindrome(s: String) -> String {
43 String::new()
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_2697() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.