Check if a string is a permutation of a palindrome in Python

Problem

Implement an algorithm in Python to check if a given input string is a permutation of another palindrome string

Solution

If the number of occurrences of all characters in the string is even then the input string can be a permutation of a palindrome string. There is only once exception which is the character in the middle. This character can can either have odd or even count. For more details, take a look at the code snippet below…

Code

Here is the code in Python…

If you run the code above you should get something like:

Thanks for visiting. For feedback, please use the comments section below.

Tags:

Add a Comment

Your email address will not be published. Required fields are marked *