Princess and Beauty
We all know that the princess is very beautiful but one day jealous from her beauty, a person asked a question from princess in order to check her wisdom. Since princess is not good at programming you need to help her in solving the problem.
You are given a string of length N. You have to check among all the the substrings that whether a substring exist or not which is palindrome and having length greater than 1. If such a substring exists then print YES else print NO.
The first line contains a single integer T, the number of test cases. Each test case is described by a single line containing a string.
For each test case, output a single line containing the YES or NO.
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 100000
Subtask #1 (20 points), Time limit : 1 sec 1 ≤ T<=10, N<=1000
Subtask #2 (80 points), Time limit : 1 sec 1 ≤ T<=10, N<=100000
Input: 2 ab babba Output: NO YES
Example case 1.The only substring whose length is greater than 1 is ab, and its not a palindrome.
Example case 2.abba is a substring of the string and its a palindrome thus YES.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.