Skip to content

Latest commit

 

History

History

palindrome-permutation-ii

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

< Previous                  Next >

Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.

Example 1:

Input: "aabb"
Output: ["abba", "baab"]

Example 2:

Input: "abc"
Output: []

Related Topics

[Hash Table] [String] [Backtracking]

Similar Questions

  1. Next Permutation (Medium)
  2. Permutations II (Medium)
  3. Palindrome Permutation (Easy)

Hints

Hint 1 If a palindromic permutation exists, we just need to generate the first half of the string.
Hint 2 To generate all distinct permutations of a (half of) string, use a similar approach from: Permutations II or Next Permutation.