BackeasyM Mixed Topics Capgemini

Palindrome Substring Enumeration Solution

Problem Statement

Given a string `sequence` of length `n`, find and return all unique substrings that are palindromes. The order of the substrings in the output should match their first occurrence in the input string `sequence`. A substring `sub` is considered a palindrome if `sub` equals its reverse (`sub` spelled backwards).

Example 1
Input
abba
Output
["a","b","bb","abba"]

Explanation: All unique substrings that are palindromes in order of their appearance

Example 2
Input
abc
Output
["a","b","c"]

Explanation: All unique substrings that are palindromes in order of their appearance

Constraints

  • The input string S will not be empty.
  • The input string S will not contain any repeated substrings.
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free