Smallest Palindromic Rearrangement I

You are given a palindromic string s.

Return the lexicographically smallest palindromic permutation of s.

Example 1
Inputs = "z"
Output"z"
A string of only one character is already the lexicographically smallest palindrome.
Example 2
Inputs = "babab"
Output"abbba"
Rearranging "babab" to "abbba" gives the smallest lexicographic palindrome.

Constraints

  • 1 <= s.length <= 10^5
  • s consists of lowercase English letters.
  • s is guaranteed to be palindromic.

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate