3517. Smallest Palindromic Rearrangement I Medium

@problem@discussion
#String#Sorting#Counting Sort



1/**
2 * [3517] Smallest Palindromic Rearrangement I
3 *
4 * You are given a <span data-keyword="palindrome-string">palindromic</span> string s.
5 * Return the <span data-keyword="lexicographically-smaller-string">lexicographically smallest</span> palindromic <span data-keyword="permutation-string">permutation</span> of s.
6 *  
7 * <strong class="example">Example 1:
8 * <div class="example-block">
9 * Input: <span class="example-io">s = "z"</span>
10 * Output: <span class="example-io">"z"</span>
11 * Explanation:
12 * A string of only one character is already the lexicographically smallest palindrome.
13 * </div>
14 * <strong class="example">Example 2:
15 * <div class="example-block">
16 * Input: <span class="example-io">s = "babab"</span>
17 * Output: <span class="example-io">"abbba"</span>
18 * Explanation:
19 * Rearranging "babab" &rarr; "abbba" gives the smallest lexicographic palindrome.
20 * </div>
21 * <strong class="example">Example 3:
22 * <div class="example-block">
23 * Input: <span class="example-io">s = "daccad"</span>
24 * Output: <span class="example-io">"acddca"</span>
25 * Explanation:
26 * Rearranging "daccad" &rarr; "acddca" gives the smallest lexicographic palindrome.
27 * </div>
28 *  
29 * Constraints:
30 * 
31 * 	1 <= s.length <= 10^5
32 * 	s consists of lowercase English letters.
33 * 	s is guaranteed to be palindromic.
34 * 
35 */
36pub struct Solution {}
37
38// problem: https://leetcode.com/problems/smallest-palindromic-rearrangement-i/
39// discuss: https://leetcode.com/problems/smallest-palindromic-rearrangement-i/discuss/?currentPage=1&orderBy=most_votes&query=
40
41// submission codes start here
42
43impl Solution {
44    pub fn smallest_palindrome(s: String) -> String {
45        String::new()
46    }
47}
48
49// submission codes end
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_3517() {
57    }
58}
59

Back
© 2026 bowen.ge All Rights Reserved.