#K59307. Palindrome Permutation Checker

    ID: 30835 Type: Default 1000ms 256MiB

Palindrome Permutation Checker

Palindrome Permutation Checker

Given a string s, determine whether any permutation of s can form a palindrome. A palindrome is a string that reads the same forwards and backwards. According to the problem, a string can be rearranged to form a palindrome if at most one character appears an odd number of times. In mathematical terms, let \( f(c) \) be the frequency of character \( c \) in \( s \). Then, \( s \) can form a palindrome if and only if

[ \sum_{c \in s} [f(c) \mod 2 \neq 0] \leq 1 ]

For example:

  • s = "aabb" → True (can be rearranged as "abba" or "baab")
  • s = "racecar" → True
  • s = "hello" → False

Your task is to implement a program that reads a string from standard input and prints True if any permutation of the string can form a palindrome and False otherwise.

inputFormat

The input is provided via standard input (stdin) and consists of a single line containing the string s. The string may be empty.

outputFormat

The output should be printed to standard output (stdout) as a single line containing either True or False depending on whether a permutation of s can form a palindrome.

## sample
aabb
True