#K60227. Palindrome Formation Check

    ID: 31040 Type: Default 1000ms 256MiB

Palindrome Formation Check

Palindrome Formation Check

Given a string S consisting of lowercase English letters, determine whether it is possible to rearrange its characters to form a palindrome without altering the frequency counts. For a string S, let ( |S| ) denote its length and ( \text{odd_count} ) denote the number of characters that appear an odd number of times. The necessary and sufficient conditions are:

  • If \( |S| \) is even, then \( \text{odd_count} = 0 \).
  • If \( |S| \) is odd, then \( \text{odd_count} = 1 \).

Output YES if S can be rearranged into a palindrome according to the above criteria; otherwise, output NO.

inputFormat

The input is provided via standard input (stdin) as two tokens separated by space. The first token is an integer ( N ) representing the length of the string S, followed by the string S which consists of lowercase English letters.

outputFormat

Output a single line via standard output (stdout): YES if S can be rearranged into a palindrome under the specified conditions, or NO otherwise.## sample

6 abccba
YES