#K53712. Palindrome Permutation
Palindrome Permutation
Palindrome Permutation
Given a string s, determine whether any permutation of the alphanumeric characters in s can form a palindrome. In this problem, spaces and all non-alphanumeric characters should be ignored, and uppercase and lowercase letters are considered equivalent.
A string can be rearranged into a palindrome if and only if at most one character has an odd frequency. More formally, if we let \(f(c)\) denote the frequency of character \(c\) (after converting the string to lowercase and filtering out non-alphanumeric characters), then there exists a permutation of the characters that forms a palindrome if and only if:
\[ \text{odd_count} = \sum_{c} \bigl[ f(c) \bmod 2 \neq 0 \bigr] \leq 1. \]Your task is to implement a program that reads a single line from standard input and prints True
if a palindrome permutation exists, and False
otherwise.
inputFormat
The input consists of a single line containing the string s. The string may include spaces, punctuation, and mixed case letters.
outputFormat
Output a single line containing either True
if any permutation of the string can form a palindrome, or False
otherwise.
aabb
True