#C2095. Rearrange to Palindrome

    ID: 45373 Type: Default 1000ms 256MiB

Rearrange to Palindrome

Rearrange to Palindrome

You are given a string s consisting of lowercase English letters. Your task is to determine whether the characters of the string can be rearranged to form a palindrome.

A palindrome is a string that reads the same forwards and backwards. For a string to be rearrangable into a palindrome, at most one character can have an odd frequency. In mathematical terms, if we denote the frequency of each character c by \( f(c) \), the string can be rearranged into a palindrome if and only if:

[ \sum_{c} \Big[ f(c) \mod 2 \Big] \leq 1 ]

For example:

  • civic can form a palindrome since its frequencies allow such a rearrangement.
  • ivicc can be rearranged to form civic.
  • hello cannot be rearranged into any palindrome.

Now, write a program that reads a string from stdin and outputs True if a palindromic rearrangement is possible, and False otherwise.

inputFormat

The input contains a single line with a string s composed of lowercase English letters only. The length of s is at least 1 and at most 10^5.

outputFormat

Output a single line containing the word True if the characters of the string can be rearranged to form a palindrome or False otherwise.## sample

civic
True

</p>