#K95012. Equal Sorted Subsequences Partitioning
Equal Sorted Subsequences Partitioning
Equal Sorted Subsequences Partitioning
Given a string \(S\) consisting of lowercase Latin letters, determine whether it is possible to partition \(S\) into two non-empty subsequences such that, when sorted individually, the two subsequences are identical.
A subsequence is a sequence that can be derived from the original string by deleting some or no characters without changing the order of the remaining characters.
Observation: A necessary and sufficient condition to achieve this partition is that there exists at least one character in \(S\) that appears at least twice. In other words, if we denote \(f(c)\) as the frequency of character \(c\) in \(S\), then the condition can be expressed in \(\LaTeX\) as:
\(\exists\, c\ :\ f(c) \ge 2\).
inputFormat
The input is provided via standard input (stdin). The first line contains an integer \(T\) representing the number of test cases. Each of the following \(T\) lines contains a non-empty string \(S\) consisting of lowercase Latin letters.
outputFormat
For each test case, print a single line to standard output (stdout) containing "YES" if it is possible to partition the string as described, or "NO" otherwise.
## sample5
abba
abcd
abacabad
a
aa
YES
NO
YES
NO
YES
</p>