#3518

Smallest Palindromic Rearrangement II

hard · 14.4% accepted · 72 likes · top 0%

hash table · math · string · combinatorics · counting

Description

You are given a palindromic string s and an integer k.

Return the k-th lexicographically smallest palindromic permutation of s. If there are fewer than k distinct palindromic permutations, return an empty string.

Note: Different rearrangements that yield the same palindromic string are considered identical and are counted once.

Solution