#C1786. Segment Palindrome Checker
Segment Palindrome Checker
Segment Palindrome Checker
Given a positive integer, your task is to determine if there exists a segment palindrome within its decimal representation that has a length greater than 1. A segment palindrome is defined as a contiguous substring of digits which reads the same backward as forward. In other words, for a given number represented as a string s of length L, you need to check if there exist indices i and j (with i < j) such that the substring s[i...j] satisfies:
$$s[i+k]= s[j-k] \quad \text{for every} \quad 0 \le k \le \frac{j-i}{2} $$If such a segment exists, output YES
, otherwise output NO
.
inputFormat
The input is read from stdin and is structured as follows:
- The first line contains an integer
t
(the number of test cases). - The following
t
lines each contain a positive integern
.
Note that each number is provided as a string of digits.
outputFormat
For each test case, output a single line to stdout containing YES
if the number contains a segment palindrome (of length greater than 1), or NO
otherwise.
2
12321
12345
YES
NO
</p>