Problem · String
Find Palindrome Sub-string
Learn this problemProblem statement
Ray likes puzzles. One day, he challenged Ansh with a puzzle to find a string that is the same when read forwards and backwards.
Write an algorithm to find the sub-string from the given string that is the same when read forwards and backwards.
Input
The input consists of a string - inputStr, representing the given string for the puzzle.
Output
From the given string, print a sub-string which is the same when read forwards and backwards.
Note
Function
findPalindromeSubString(inputStr: String) → StringExamples
Example 1
inputStr = "YABCCBAZ"return = "ABCCBA"Given string is "YABCCBAZ", in this only sub-string which is same when read forward and backward is "ABCCBA".
Example 2
inputStr = "ABC"return = "None"Given string is "ABC", and no sub-string is present which is same when read forward and backward. So, the output is "None".
Constraints
🍅🍅