#C8629. Balanced String Rearrangement
Balanced String Rearrangement
Balanced String Rearrangement
You are given a string s
consisting of lowercase Latin letters. Your task is to determine whether the string can be rearranged into a balanced string. A string is considered balanced if it can be partitioned into two identical halves. Formally, let \( n = |s| \) be the length of the string. The string can be rearranged into a balanced string if and only if:
- \( n \) is even, and
- for every character \( c \), its frequency \( f_c \) satisfies \( f_c \equiv 0 \pmod{2} \).
If these conditions are met, output YES
; otherwise, output NO
.
inputFormat
The input consists of a single line containing the string s
.
You should read the input from stdin.
outputFormat
Output a single line containing YES
if the string can be rearranged into a balanced string, and NO
otherwise. Write the output to stdout.
aabbccdd
YES