Palindrome Permutation

Try to solve the Palindrome Permutation problem.

Statement#

For a given string, st, find whether or not a permutation of this string is a palindrome. You should return TRUE if such a permutation is possible and FALSE if it isn’t possible.

Constraints:

  • 11 \leq st.length 1000\leq 1000
  • The string will contain lowercase English letters.

Examples#

Created with Fabric.js 3.6.6 The string has three permutations: aba, aab, and baa.aba is a palindrome. aab Ouput TRUE Sample example 1Input

1 of 2

Created with Fabric.js 3.6.6 Sample example 2Input acb FALSE Ouput The string has five permutations: acb, bac, bca, cab, and cba.None of the permutations is a palindrome.

2 of 2

Understand the problem#

Let’s take a moment to make sure you’ve correctly understood the problem. The quiz below helps us to check if you’re solving the correct problem:

Palindrome Permutation

1

The string “abb” has a permutation that’s a palindrome.

A)

TRUE

B)

FALSE

Question 1 of 20 attempted

Figure it out!#

We have a game for you to play. Rearrange the logical building blocks to develop a clearer understanding of how to solve this problem.

Drag and drop the cards to rearrange them in the correct sequence.

Traverse the input string starting from the first character.

Populate a hash map with the characters in the string, along with the frequency of occurrence of each character.

Traverse the hash map to get the count of characters with an odd number of occurrences.

If the count exceeds 1, no palindromic permutation exists.


Try it yourself#

Implement your solution in main.py in the following coding playground. We have provided a useful code template in the other file that you may build on to solve this problem.

Python
main.py
populating_hashmap.py
Input #1
Palindrome Permutation

Knowing What to Track: Introduction

Solution: Palindrome Permutation