longest palindromic substring python
class Solution(object):
def longestPalindrome(self, s):
dp = [[False for i in range(len(s))] for i in range(len(s))]
for i in range(len(s)):
dp[i][i] = True
max_length = 1
start = 0
for l in range(2,len(s)+1):
for i in range(len(s)-l+1):
end = i+l
if l==2:
if s[i] == s[end-1]:
dp[i][end-1]=True
max_length = l
start = i
else:
if s[i] == s[end-1] and dp[i+1][end-2]:
dp[i][end-1]=True
max_length = l
start = i
return s[start:start+max_length]
ob1 = Solution()
print(ob1.longestPalindrome("ABBABBC"))
Log in, to leave a comment
3.6
5
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
// expand in both directions of low and high to find all palindromes
void expand(string str, int low, int high, auto &set)
{
// run till str[low.high] is a palindrome
while (low >= 0 && high < str.length()
&& str[low] == str[high])
{
// push all palindromes into the set
set.insert(str.substr(low, high - low + 1));
// expand in both directions
low--, high++;
}
}
// Function to find all unique palindromic substrings of given string
void allPalindromicSubstrings(string str)
{
// create an empty set to store all unique palindromic substrings
unordered_set<string> set;
for (int i = 0; i < str.length(); i++)
{
// find all odd length palindrome with str[i] as mid point
expand(str, i, i, set);
// find all even length palindrome with str[i] and str[i+1] as
// its mid points
expand(str, i, i + 1, set);
}
// print all unique palindromic substrings
for (auto i : set)
cout << i << " ";
}
int main()
{
string str = "google";
allPalindromicSubstrings(str);
return 0;
}
Thank you!
5
0
Are there any code examples left?
New code examples in category Python
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Relative searches
check 2 strings are palindrome or not
Find all distinct palindromic sub-strings of a given string
find all palindromic substrings in a given string
get the longest match in a string python
print all the possible palindromes in a given string
longest palindromic substring brute force python
find if palindromic substring is present
count palindrome substring numbers in a given range hackerearth
Check if a string contains a palindromic substring
Check if substring is palindrome
count palindrome substring numbers in a given range
count numbers whose string representation does not have a palindromic substring
count numbers whose string representation doesnt have a palindromic substring
Count all Palindrome sub-string in given String
print longest palindrome in a string
longest palindromic subsequence program in python
what is palindrom string
ongest Palindromic Substring
Longest Palindromic Subsequence in python
length of the longest palindromic substring
two palindromic substring of a given string
count all palindromic substring of s
how to find palindromes in a string in O(n)
find all distinct palindromic substrings of a given string
find longest palindrome in a string python
iven a string and find the number of substring which is palindrome.
All possible fake palindrome substrings
length of longest substring solution python
sorting palindrome string
print all palindromes in a string
, print all palindromic substrings of it.
count palindrom substrings of a string
longest palindrome subsequence in the given string
Palindromic Substrings (/problems/palindromic-substrings)
subsctring in palindrome
biggest palindrome substring
count palindromic substring using manacher's algorithm
count palindromic substrings using manicure
convert the given string to palindrome string
number of palindromic substring gfg
get longest of two strings python
check whether all palindromic substring of strings are odd length
given the string check if there is a palindrome substring
count all palindrome subsequence in a string
the longest string python
longest string python
find the longest palindrome in a string python
find the longest palindrome in a given string
what should be the longest python variable name ?
get longest word in string python3
number of palindromes from a given string
to check string palindrome or not and reverse string
count the number of palindromic substring in given string
palindromic substrings in a string
longst palindrome substring
palindrome strings example
palindromable string
find the longest substring in python
string generate with no palindrome as a substring
longest palindrom substring
find all palindrome substring in a string
string containing a substring and palindrome hackerrank
string contaning a substring and palidrome
number of palindromic substring in a string with length n
number of palindromes in string with length n
what is longest palindromic substring
find the longest palindromic substring in pythosn
From given string “1123442”, find all substrings which can be palindromes. Substrings need not be present in palindrome itself, It needs to be re-arranged. Example: Palindrome substrings can be
From given string “1123442”, find all substrings which can be palindromes. Substrings need not be present in palindrome itself, It needs to be re-arranged. Example: Palindrome substrings can be\
find all substrings which can be form palindrome by rearranging them
find all substrings which can be palindrome
Given a string S, check if it is palindrome or not.
print all sub palindromes in a string
Length of longest palindromic substring in a string.
find longest word in a string python
length of longest palindrome in a string
palindromic substring loop based
Comparing strings and palindrome
to find out longest palindrome in a given string
find the longest substring in a string python
Given a string abc. Display all palindromes to the string
find out longest palindrome in a given string
longest palindromic substring python applicationai
manacher's algorithm for palindromic substring
longest substring in pyhton
prijt palindromic subsequences in a string
find all palindromic subsequences in a string
number of palindrome in a strinf
longest palindrome in word python
find palindrom subsequence of length 3 of a given string
find palindrom subsequence of a given string
palindromic subsequences of string
print find all subsequence of palindrome in python
print all the palindromic subsequence of a given string
print all the palindromic subsequence substrings of a given string
find length 3 subsequence which is palindrome in string
palindrome of legth n in string
how to obtain palindromic subsesequence of a string of specific length
how to obtain palindromic subsesequence of a string
find number of unique palindromes of length 3 in the string
what is palindromic substring
A string is an almost-palindrome if by changing only one character, you can make it a palindrome.
number of palindromes in a substring
longest palindromic substring explanation
Write a program to find all the palindrome words in a string .
longest palindromic subsquence python solution
find all palindromic subsequences of a string
substring palindrome
number of unique palindromic substrings
how to remove palindrome substring in a string
find longest word python in string
find longest word python
check if a string is palindrome
palindromicsubstring(str)
you are given string s and we have to find palindrome subsequence
count substrings that can be arranged into palindrome
number of substrings that can be arranged in palindrome
1. Longest Palindrome in a string
longest substring in python
. Longest Palindrome in a string
All possible fake palindrome substrings (Fake palindrome- whether a string has any possibilities of palindrome)
condition for a string to be palindrome
string with n palindromic substrings
is single character string a palindrome
longest word in string python
efficiently find palindromic substrings
given n queries and a string we have check where a substring i j is palindrome or not
python palidromes in substring index
largest substring palindrome from given string python
print all palindromic substrings of a given string
test cases for palindrome string
palindromic substring gfg practice
Number of palindromic substrings in a given string
find out palindromic substrings with in a string.
count palindrome sub-strings of a sentence
finding longest palindrome in a string python
find longest string that appears at end of another string python
find longest string that appears at end of other string python
in the given string check and count palindrome string and int
Longest Palindrome Sub string
program to find a string is palindrome or not
how to find longest word in a string python
python find longest substring
how to get the longest match pytohn
Find occurrences of palindrome words in a string
find the longest palindromic substring.
Count All Palindrome Sub-Strings in a String Ask Question
Find all scatter palindrome strings inside given string. A scatter palindrome is defined as a string in which characters can be shuffled to obtain a palindrome.
find the longest palindrome from a given string
given a string make it palindrome
palindromic substrings codechef solution
longest palindromci substring
make all substr of length k as palindrome
find the number of substrings which are palindrome
A palindrome is a string that reads the same from the left and from the right. For example, mom and tacocat are palindromes, as are any single-character strings. Given a string, determine the number of its substrings that are palindromes.
palindrome string or not
longest way to print a string in python
How do you check if a given string is a palindrome?
how to find number of all palindrome substrings in a string
return string with longest length python
longest word in a string python
print longest palindromic substring
2.Longest Palindrome in a string
all palindrome substring
all palindromic substring recurrsion
palindromic substring recurrsion
print all possible palindrome of string
longest palindrome substring tutorial
How do you find the longest palindromic substring of a given substring?
all palindrome substring python
palindrome substring greater than len 2
Check String Palindrome, finding all the palindrome strings using DP.
Return the number of Fake Palindrome substring in a string, where Fake Palindrome is a string whose anagram is a palindrome
longest palindrome characters count in python
make a string palindrome
Convert given string to palindrome with given substring
how to find longest palindrome in a string
longest palindromic subsequence python
number of palindromes strings in a given range
longest palindrome substring python
Find the longest possible palindrome of from a given string
example of a palindrome substring
what is a palidrome substring
how to find longest sequence in python string
a string with multiple palindromes in it
make a palindromic string from a given string
no. of palindrome strings
Given a string return all the palindromes that can be obtained by its characters
find all palindromic substring of given length in O(n)
find all palindromic substring of given length in O(1)
find all palindromic substring of given length
find all palindromes in a string with given length
check if two strings are palindrome login complexity
count palindromic substrings gfg
python find longest word in string
longest palindromic substring dynamic programming python
return the longest palindromic substring in python
Distinct palindromic substrings
return the longest palindromic substring
print palindromic substrings
find all non single letter substrings palindrome
list of palindromes in string
I wish to determine if a given string is a palindrome
longest substringg python
palindromic subsequence of a string
palindromic substring manacher
checking substring of a string to be palindrome using dp
valid palindrome ii string
check if substings of a string is palindrome
all substrings palindrome
find longest match python
number of palindrome in a string
5. Longest Palindromic Substring
find the longest palindromic substring of a given substring
count palindromic substring
given a string determine the number of its substrings that are palindromes
count number of palindromes in a string
python take longest word in string
Function of palindrome in string
palindrome of string
find out longest palindrome in a given string. Assume that the string has both palindrome and non-palindromes.
check a string is palindrome or not
ololngest palindrom in a string best method
how to find number of palindromes in a string
Count of Palindromic Substrings
check string is palindrome reccursion
count number of palindrome substring in given string
n strings palindrome or not
Find the number of substring which palindrome.
how to find the longest word in a string python
even string length palindrome example
count all palindromic subsequence in a given string
loop to find palindrome
longest Substring Find in python
How many palindromes are there in the given string.
what is palindrome string
calculate palindrome string
string palindrome subsequences
find all possible palindrome from given characters
find all possible palindromes from given characters
find all possible palindromes using characters of a given string
find all the palindrom using character
number of palindromic substring
how to find the longest palindrome in a string
palindromes formed by string
longest palindromic substring using strings
maximum palindrome substring
examples of string palindrome
finding all substring palindrome using dp
to find two palindromic substring in a string
all the palindromic subtring in stl
Count All Palindromic Subsequence in a given String.
palindrome for string
finding the longest palindromic substring codebyte
finding the longest palindromic substring.
function to find out longest palindrome in a given string
Given a string of strings, print the number of palindromes present
palindromic substring problem solution
given a string find the largest sub palindrome substring
check string is palindrome and return not palindrome string
Write a function to find the longest Palindrome in a string
palindrome substrings
how to find palindrome substring in a string ignoring punctuation
what is a palindrome string
maximum palindromic substring
Write a function that determines if a string in a palindrome
check if string is palindrome
find longest palindrome substring in a string
find number of alternate all palindrome substring in a string
find all number palindrome substring in a string
how many palindromic substring in a palindromic string
PALINDROME STRING EXAMPLE
find longest string in python
longest palindrome substring print
print all the palindromes from the given string
find palindromic substring in string
find the palindromic substring in an array of integers
find the palindromic substring
how many palindromes are there in the given string simple
How many palindromes are there in the given string
longest palindrome in a string
how to find longest possible substrings of a string in python
find palindrome in string with set
find the number of distinct palindromic substrings in given string
string palindrome
make string palindrome
count palindrome sub-strings of a string
Palindromic Substrings
Given the string, check if it is a palindrome.
count of palindromic substring
find longest word in sentence python
Harry's spell must not contain palindromic substring of length more than or equal to X.
given a palindrome string make it non plaindrome
palindrome substring queries
check whether substring can be rearraned to a palindrome
find longest matching substring python
count palindromic substrings
count palindromic subsequnces of string
Return the number of Fake Palindrome substring in a string
palindrom substring
find longest word in string python
is palindrome string
fake palindrome sub substrings in a string
Get all palindromic substring from string
How to check if String is Palindrome?
How do you search for a palindrome in a string of characters
write a program to find palindrome of given string
check string is palindrome or not
Find the largest palindrome substring from a string.
python longest word in string
longest python code
longest substring palindrome
palindrome string
find the longest word in a string python
how to find subsequence with palindromic string
given string is palindrome number or not
longest substring using python
string is palindrome or not
how to check string is palindrome or not
how many palindromes string can be formed from a given strings
match two string for palindrome
Program to check given string is palindrome or not
A palindrome is a string that reads the same forward and backward. Describe an algorithm for determining whether a string of n characters is a palindrome.
longest palindrome substring with length and string
palindromic substring meaning
how can i find the longest string in python
count all palindrome sub-strings in a string
longest possible strings using python
how to rearrange substring of string in palindrome
find all possible palindromic substring with more than 1 character of a string
find all possible palindromic substring of a string
check if string contains palindrome as substring
palindrome subsstring
no of palindrome in given string
palindrome of a string
find all palindromic substrings from the given string
Each of these substrings is a palindrome with length greater than 1
find all palindrome substrings and replace with ***
example of palindrome string
count all palindromes in the given string
all longest string python
python find the longest word in a string
Find the longest Palindrome in a given string.
print all palindrome substrings in a string
count all palindrome substrings in a string
Find the longest palindromic substring in the given string
longest palindrome substring
given a string find number of different substrings that are palindromes
get longest word in string python
how to find string length from list
palindrome of a string optimized solution
max length in python
number of possible palindromes from a given string
return all palindromes in a string leetcode
return all palindromes in a string
how to find longest word in a list python
Given a string s, determine whether any anagram of s is a palindrome.
find longest str in list
using regex to find the largest palindrome in a string
print the longest variable value in python
max in python length
find the palindrome in the given string
print longest word in a string python
how to print all the substrings which are palindromic
get max length of string in list python
python max character list
palindrome substring
paloindrome not continuoud substring
python get longest run of characters
python find shortest string in list
identifying subbstrings palindrome
all possible palindromes in a string
longest palindromic substring python
palindromic substring recyrsion
find the longest palindrome in a string
longest substring python
palindromic substring
how to find sub palindomres
number of substrings of a string that are palindromes
find palindrome substring in string in java
find longest palindrome substring from given string
find all the pallidromic substring in a string
palindromic substring of a string
print palindromic substring c++
palindromic substring c++
find all palindrome substrings
find palindromic substring
find palindrome in string
python largest string in list
return array of longest strings python
return longest string in list python
how to get the longest string in a set python
how to get the longest string in a list python
find min and max len words in list pythn
find the biggest string
palaingdrom subset c++
python longest string in list
finding the number of sub palindromes in a string
python find max length in list
all possible palindromic substrings in a string
python get the longest string in a list
python program to find maximum length of string from a input
python program to find maximum length of string
chaeck the substring of the given string is palindrome is o r not
max string length in list python
max length string in list python
python get longest string in list
get length of longest string in list python
scatter palindrome hackerrank solution
largest string python
find longest string in list python
number of palindrome substrings in a string
python method that findds the longest element string
Find all palindromic substrings of a n length string
longest string in list python
how to find the longest string in a list python
get the longest string in a list python
python find the longest string in a list
get longest string in list python
python get string with max length
find the longest 0s in a string python
longest element in list python
get max length of elements in list python
print all palindromic substrings
max length of string in list python
how to find longets item in a python string list
how to find the longest string python
fake palindrome substring
find palidrome in the string
find substring polindrom
find all substrings which are not substring of other palindrome python
how to find all palindrom substings from a string
how to find all substring palindrome out of a string
all pallindrome substring of string even 1 length
Given a string,print all the sub-strings that are palindrome.
find. apallindrome in string
how to find all the palindromes
Scatter Palindrome : Given a vector of strings, for each string, find the no. of substrings in it which can be rearranged into a palindrome.
search for pallindrome in string
find all subpalindromes of a string
Print all the palindromic substrings of a given string
find all palindromic sub-strings of a given string
palindromic strings
finding palindromic substrings within a string
generate all palindromes of a string
number of palindromic substrings in a string
all palindromic substrings in a string
find paindrome in a string
how to find a string with 3 palindromes in it
Given a string, determine the number of its substrings that are palindromes in java
Given a string, determine the number of its substrings that are palindromes.
find all the palindrome sub-strings in a string
how to find palindrome substring in a string
Print all palindromic substrings of the given string
find all palindromes in a string
all substrings of a string thAT ARE PALINDROMES
all palindromic substring
find all the palindrome substring in a given string