#K12096. Palindrome Permutation Check
Palindrome Permutation Check
Palindrome Permutation Check
Given a string, determine whether any permutation of the string can form a palindrome. A palindrome reads the same forwards and backwards. The key observation is that in a palindrome, at most one character can appear an odd number of times. Mathematically, if we denote the frequency of a character c in the string by \(f(c)\), then a permutation of the string can form a palindrome if and only if:
$$\sum_{c \in S}{[f(c) \mod 2 = 1]} \le 1.$$
Your task is to read the input string from standard input and print YES
if a palindrome permutation exists and NO
otherwise.
inputFormat
The input is a single line containing a non-empty string s consisting of lowercase English letters.
Input Format:
s
outputFormat
Print a single line with YES
if any permutation of the string can form a palindrome, or NO
otherwise.
civic
YES