#K14461. Palindromic Substring Checker
Palindromic Substring Checker
Palindromic Substring Checker
Given a string s and an integer n, determine whether there exists a contiguous substring of length n in s that is a palindrome. A string is considered a palindrome if it reads the same forwards and backwards, i.e., it satisfies $$ s = s^{R} $$. This problem requires you to check all possible substrings of length n in s and output "YES" if at least one of them is a palindrome, otherwise output "NO".
Note: The input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
inputFormat
The first line of input contains the string s
.
The second line contains the integer n
, which is the length of the substring to be checked.
outputFormat
Print a single line containing either "YES" if there exists a palindromic substring of length n
within s
or "NO" otherwise.
abccba
4
YES