Find all Palindrome Substrings
Given a string, find all substrings that are palindromes.
Statement
Given a string, find all non-single letter substrings that are palindromes.
A palindrome is a word, phrase, number, or other sequence of characters that reads the same backwards as it reads forwards.
Example
Below is an example of all possible non single-letter palindromes of string aabbbaa
:
Sample input
Input string to find non single-letter substring.
Input string: "aabbbaa"
Expected output
The expected output of the above string will be:
Palindrome substrings: ["aa", "bb", "bbb", "abbba", "aabbbaa", "bb", "aa"]
Try it yourself
#include <iostream>#include <string>#include <vector>using namespace std;// This function receives input_string and returns palindromes listvector<string> FindAllPalindromeSubstrings(const string& input_string) {//TODO: Write - Your - Codereturn {""};}
Solution 1
A naive solution of this problem is to find all substrings of a given string and check whether each substring is a palindrome or not. This solution has a complexity of ...
Access this course and 1400+ top-rated courses and projects.