Problem · String
Alphabetically Smallest Palindrome
Learn this problemProblem statement
A palindrome reads the same from either direction; for example, ada is a palindrome. You are given a string s of lowercase English letters.
Change the fewest letters possible so that the characters of s can be rearranged to form a palindrome. If multiple palindromes require the same minimum number of changes, return the alphabetically smallest one.
Function
makeAlphabeticallySmallestPalindrome(s: String) → StringExamples
Example 1
s = "azzzbbb"return = "abzbzba"Optimally, change one z to a to get aazzbbb. These letters can be rearranged to form abzbzba, which is the alphabetically smallest palindrome possible after one change.
Constraints
1 ≤ s.length ≤ 3 × 10^5sconsists of lowercase English letters only.
More Microsoft problems
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026
- Maximum Strength of Every NeuronOA · Seen Jul 2026
- Neural Network Subnetwork StrengthOA · Seen Jul 2026
- XOR MultiplicationOA · Seen Jul 2026
- Escape Game - Maximize ScoreOA · Seen Jul 2026