Problem ยท String
Find Longest Palindromic Substring ๐ผ
Learn this problemProblem statement
The input consists of a string inputStr, representing the given string for the puzzle.
From the given string, print a substring which is the same when read forwards and backwards.
Note
- If there are multiple sub-strings of equal length, choose the lexicographically smallest one.
- If there are multiple sub-strings of different length, choose the one with maximum length.
- If there is no sub-string that is the same when read forwards and backwards print "None".
- Sub-string is only valid if its length is more than 1.
- Strings only contain uppercase characters (A-Z).
Function
longestPalindrome(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
Unknown for nowMore Cisco problems
- Collect CoinsSeen Jun 2025
- FizzBuzz ProblemSeen May 2025
- Find Largest Sum Contiguous SubarraySeen May 2025
- Find Largest Sum of Continuous SequenceSeen May 2025
- Find Palindrome Sub-stringSeen May 2025
- Count Numbers with Digit SumSeen Mar 2025
- Maximum Chocolates from Jars (L.C. 198 :)Seen Mar 2025
- Find Elements Largest in Row Smallest in ColumnSeen Mar 2025