#C8886. Palindromic Subsequence Finder
Palindromic Subsequence Finder
Palindromic Subsequence Finder
You are given a string S. Your task is to determine whether there exists a subsequence of S that forms a palindromic string of length greater than 1. A subsequence is a sequence that can be derived from S by deleting some or no characters without changing the order of the remaining characters.
The simplest way for such a subsequence to exist is if S contains at least two identical characters. These two characters, taken in order, form a palindrome of length 2.
For example, in the string "abcba", the characters 'a' at positions 1 and 5 form a palindromic subsequence "aa". Conversely, if the string is "abcd", no two identical characters occur, so no palindromic subsequence of length at least 2 can be formed.
You need to answer "YES" or "NO" for each test case.
inputFormat
The first line of input contains a single integer T (T ≥ 1) representing the number of test cases. The following T lines each contain a non-empty string S. Each string consists of letters and/or digits.
outputFormat
Output T lines. For each test case, print "YES" if there exists a palindromic subsequence of length greater than 1 in the string, otherwise print "NO".
## sample3
abcba
abcd
aa
YES
NO
YES
</p>