Palindromic Sub-String <P2SME>
Practice
2.2 (4 votes)
Basic programming
Easy
String manipulation
Problem
86% Success 1404 Attempts 20 Points 5s Time Limit 256MB Memory 1024 KB Max Code

You are given a string S. You have to check if there exists a sub-string X of string S having length greater than 1 such that the string X and its palindrome both are present as sub-string in the string S.

Note: String X and its palindrome string may overlap.

Input
First line contains a string S as input.

Output
Print YES if there is a sub-string X as described above and in the next line print the length of maximum sub-string among all that satisfies this condition.
If there is no sub-string that satisfies the above condition print NO.

Constraints
\(1 \le |S| \le 50\) where S is the length of string S.
String S contains lowercase English letters only.


Help on using the given code snippet
Suppose that your answer is NO then you need to return the string NO or else you have to return the string YES . "\n" . $val where $val is the answer. The two ways of using the given code snippet are shown below


function process_string ($S)
{

    // Complete this function and return the appropriate value
    // The format of returning the value if explained above
    return "NO";
}

function process_string ($S)
{

    // Complete this function and return the appropriate value
    // The format of returning the value if explained above
    return "YES" . "\n" . $val;
}


Note: It is not mandatory to use the code snippet that is provided to you in the editor by default. It is just to make the question more convenient. You can completely remove the default code and submit your solution in the appropriate format.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
30 votes
Tags:
Basic ProgrammingEasyString Manipulation
Points:20
27 votes
Tags:
ImplementationBasic ProgrammingBasic Math
Points:20
38 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyImplementation