#K53372. Permutation Palindrome
Permutation Palindrome
Permutation Palindrome
Given a string s, determine if any permutation of the string can form a palindrome. A string can be rearranged to form a palindrome if and only if the number of characters with an odd count is at most one. In mathematical terms, if we denote the frequency of each character by \(f(c)\), then the string is palindromic if
[ \sum_{c}\left[ f(c) \bmod 2 \neq 0 \right] \leq 1, ]
where \(\left[ f(c) \bmod 2 \neq 0 \right]\) is 1 if \(f(c)\) is odd and 0 otherwise. Your task is to implement a solution that reads an input string from stdin and prints True
if some permutation of the string can form a palindrome, and False
otherwise.
inputFormat
The input consists of a single line containing a string s. The string may be empty and will consist of only visible characters.
outputFormat
Output a single line: True
if any permutation of the string can form a palindrome, otherwise False
.
civic
True