Palindrome Word
Updated
Problem statement
A palindrome reads the same forwards and backwards. For example, "azbza" is a palindrome, and it has the palindrome "zbz" nested inside it.
You are given a string s. Return every palindromic substring of s that has at least 3 characters.
- Comparisons are case-sensitive:
"a"and"A"are different. - Order the results by increasing start index. When several palindromes start at the same index, list the longer one first.
- Keep duplicates: the same text found at different positions appears once for each position.
- If there are none, return an empty list.
For example, for "aCacfzFccFzq" the answer is ["aCa", "zFccFz", "FccF"]. "Cac", "fzF" and "cfzFc" are not included because of case sensitivity.
Function
printAllPalindromes(s: String) → String[]Examples
Example 1
s = "aCacfzFccFzq"return = ["aCa", "zFccFz", "FccF"]The function returns all palindromes of 3 or more characters in length contained in "aCacfzFccFzq". The matching case-sensitive substrings are "aCa", "zFccFz", and the nested palindrome "FccF".
Constraints
1 ≤ s.length ≤ 100scontains only English letters (atozandAtoZ).
More Epic interview questions
Similar questions at other companies
- String CompressionAbridge · OAAbridge interview questions
- K Smallest SubstringAkuna Capital · OAAkuna Capital interview questions
- Format TextTikTok · OATikTok interview questions
- Next Greater Element IIIThe Walt Disney Company · OAThe Walt Disney Company interview questions
- Counting Binary Substrings (Backend)Canva · OACanva interview questions
- Shortest SubstringRippling · OARippling interview questions
- Minimum Swaps to Make PalindromeAmazon · OA
- Longest Subsequence That Is a SubstringExpedia · OAExpedia interview questions
- String Search (Also for Core/Database Engineering)Snowflake · OASnowflake interview questions
- Count SubstringsSalesforce · OASalesforce interview questions