[LeetCode 267] Palindrome Permutation II

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

For example:

Given s = "aabb", return ["abba", "baab"].

Given s = "abc", return [].

Hint:

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

Diffculty
Medium

Similar Problems
[LeetCode 31] Next Permutation Medium [LeetCode 46] Permutations Medium [LeetCode 47] Permutations II Medium [LeetCode 266] Palindrome Permutation Easy

Analysis

results matching ""

    No results matching ""