java.lang.Object
g3501_3600.s3517_smallest_palindromic_rearrangement_i.Solution

public class Solution extends Object
3517 - Smallest Palindromic Rearrangement I.

Medium

You are given a palindromic string s.

Return the lexicographically smallest palindromic permutation of s.

Example 1:

Input: s = “z”

Output: “z”

Explanation:

A string of only one character is already the lexicographically smallest palindrome.

Example 2:

Input: s = “babab”

Output: “abbba”

Explanation:

Rearranging "babab" \u2192 "abbba" gives the smallest lexicographic palindrome.

Example 3:

Input: s = “daccad”

Output: “acddca”

Explanation:

Rearranging "daccad" \u2192 "acddca" gives the smallest lexicographic palindrome.

Constraints:

  • 1 <= s.length <= 105
  • s consists of lowercase English letters.
  • s is guaranteed to be palindromic.
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • smallestPalindrome

      public String smallestPalindrome(String s)