#K34177. Palindromic Substring Finder
Palindromic Substring Finder
Palindromic Substring Finder
Given a string s consisting of lowercase alphabets, determine whether there exists any palindromic substring of length at least 3 in s. A palindrome is a sequence of characters that reads the same forwards and backwards.
More formally, for a given string s with length n, you need to check if there exists any substring s[i...j] (with \( j - i + 1 \geq 3 \)) such that:
\( s[i\dots j] = \text{reverse}(s[i\dots j]) \)
If such a substring exists, output YES
; otherwise, output NO
.
inputFormat
The input consists of a single line containing a string s of lowercase alphabets.
Constraints: \( 0 \leq |s| \leq 10^4 \).
outputFormat
Output a single line containing YES
if there exists a palindromic substring of length at least 3, and NO
otherwise.
abcdefg
NO