Class Solution
java.lang.Object
g2601_2700.s2697_lexicographically_smallest_palindrome.Solution
2697 - Lexicographically Smallest Palindrome.<p>Easy</p>
<p>You are given a string <code>s</code> consisting of <strong>lowercase English letters</strong> , and you are allowed to perform operations on it. In one operation, you can <strong>replace</strong> a character in <code>s</code> with another lowercase English letter.</p>
<p>Your task is to make <code>s</code> a <strong>palindrome</strong> with the <strong>minimum</strong> <strong>number</strong> <strong>of operations</strong> possible. If there are <strong>multiple palindromes</strong> that can be made using the <strong>minimum</strong> number of operations, make the <strong>lexicographically smallest</strong> one.</p>
<p>A string <code>a</code> is lexicographically smaller than a string <code>b</code> (of the same length) if in the first position where <code>a</code> and <code>b</code> differ, string <code>a</code> has a letter that appears earlier in the alphabet than the corresponding letter in <code>b</code>.</p>
<p>Return <em>the resulting palindrome string.</em></p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> s = “egcfe”</p>
<p><strong>Output:</strong> “efcfe”</p>
<p><strong>Explanation:</strong> 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’.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> s = “abcd”</p>
<p><strong>Output:</strong> “abba”</p>
<p><strong>Explanation:</strong> 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”.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> s = “seven”</p>
<p><strong>Output:</strong> “neven”</p>
<p><strong>Explanation:</strong> 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”.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= s.length <= 1000</code></li>
<li><code>s</code> consists of only lowercase English letters**.**</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
makeSmallestPalindrome
-