#K5251. Can Form Palindrome?
Can Form Palindrome?
Can Form Palindrome?
You are given a string s
. Your task is to determine whether any permutation of the string can form a palindrome. In other words, check if it is possible to rearrange the letters in s
such that the resulting string is a palindrome.
A string is a palindrome if it reads the same forwards and backwards. Mathematically, a string can be rearranged to form a palindrome if and only if the number of characters with an odd frequency satisfies \[ \text{odd_count} \le 1 \] where \(\text{odd_count}\) is the number of characters that appear an odd number of times (after ignoring non-alphabetic characters and case).
Note: The input string may include spaces, punctuation, and mixed-case characters. Only alphabetic characters should be considered (case-insensitive).
inputFormat
The input consists of a single line which contains the string s
. The string may contain spaces, punctuation or other non-alphabetic symbols.
outputFormat
Output a single line with either True
if the string can be rearranged to form a palindrome, or False
otherwise.
civic
True
</p>