FrontendX
Palindrome Permutation II
medium
Description
AI Assistance
Solution
Test Cases
Test Result
Submissions
Canvas
Palindrome Permutation
II
Given a string s, return all possible palindromes that can be formed by permuting its characters.
Examples
Example 1
Input:
"aabb"
Output:
["abba","baab"]
Example 2
Input:
"abc"
Output:
[]
Hints
Hint 1
First check if palindrome permutation is possible (at most one odd count).
Hint 2
Generate the first half, then mirror it.
Hint 3
Handle the middle character if there's an odd count.
Related Problems
24-game
additive-number
all-paths-from-source-to-target
Palindrome Permutation II
Given a string s, return all possible palindromes that can be formed by permuting its characters.