What is the difference between palindrome permutation and permutation? [closed]

These two questions typically differ based on how they’re framed. Usually, the string permutation question is asked as

Given a string w and a string x, check whether w is a permutation of x.

In that sense, you know what both strings are, and you just need to see whether the character counts match (or whether they have the same sorted order, etc.)

The palindrome permutation problem is typically asked as

Given a string w, determine whether there is a string x where x is a palindrome and w is a permutation of x.

So in this case, you’re just given a single string w and need to figure out whether somewhere out there there’s a palindrome that it’s a permutation of. This problem is different, since you don’t have an explicit target string to compare against and you need to have the creative insight of counting up the counts of each character to see whether there are exactly zero or one characters that appear an odd number of times.

The general problem of “is w a permutation of x?” ceases to be interesting if you reframe it as “is w a permutation of some string?” because the answer is an immediate “yes,” and the problem of “is w a permutation of some palindrome?” loses its charm if you reframe it as “is w a permutation of the palindrome x?” because it’s essentially the same as the general permutation problem.

Leave a Comment