Find Palindrome Sub-string
Updated
Problem statement
You are given a string inputStr. Find a substring that reads the same forwards and backwards (a palindrome).
- Only substrings of length
2or more count. - Return the longest such substring.
- If several have the same longest length, return the lexicographically smallest one (the one that comes first in alphabetical order).
- If there is none, return
"None".
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
1 ≤ inputStr.length ≤ 1000inputStrcontains only uppercase English letters (AtoZ).
More Cisco interview questions
- Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
- Find Unique ElementsPHONE SCREEN · Seen Nov 2026
- First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
- Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a StringPHONE SCREEN · Seen Nov 2026
- Valid ParenthesesPHONE SCREEN · Seen Nov 2026
- K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
- Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
- Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Longest Palindromic SubsequenceAXQ Capital · OA
- Maximum Equal-Bit Pairs in a SubsequenceAmazon · OA
- Longest Subsequence That Is a SubstringBooking.com · OA
- Count Digit Replacements with No Equal Adjacent DigitsMicrosoft · OAMicrosoft interview questions
- Palindrome CounterGoldman Sachs · OAGoldman Sachs interview questions
- Longest String ChainVisa · OAVisa interview questions
- Minimum-Cost Digit String DecodingSquadStack.ai · OA
- Maximum Redundancy After One Segment FlipBloomberg LP · OABloomberg LP interview questions
- Substrings Without a Target SubsequencePhonePe · OAPhonePe interview questions
- Minimum Edit-Distance String for Each QueryTarget · OA