bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 267. Palindrome Permutation II

267. Palindrome Permutation II

Leetcode Solutions

Approach # Backtracking

  1. Create a hashmap to count the occurrences of each character in s.
  2. Check if a palindromic permutation is possible by ensuring at most one character has an odd count.
  3. Form a string st with half the occurrences of each character (and one odd-count character, if any).
  4. Use backtracking to generate permutations of st.
  5. For each permutation, create a palindrome by appending the reverse of the permutation (and the odd-count character in the middle, if any).
  6. Return the list of generated palindromic permutations.
UML Thumbnail

Approach # Brute Force

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...