Longest Plaindrom From The Sequence of String
Longest Plaindrom From The Sequence of String
input = "amadambba"
the brute force appraoch says that if the given string is there then take pointers
and then check every single
value of the string and check the palindrome it takes O(n^2) time compliexity
one optimal solution is that take two pointers from left and right
and store that value in the matrix , the major benfit is that when you check the
value of palindrome of largest string and that string is
already is store in the matrix so that the time complexity is already reduce
hinit is that add that value in matrix until and take two pointers from that we can
higest value
example : aabaa
matrix is that
a a b a a
a 1 2 0 0 5 <= longest palindrom
a 1 0 3 0
b 1 0 0
a 1 2
a 1
// vector is used for extenable array we can grow size or shrank like linked list
class solution {
public string longestPalindrome (String s) {
int len = s.length();
int maxlen = 0;
string ans; // this is used for storeing the final value of
longest palaindrome from the string
vector<vector<int>> dp (n,vector<int>(n,0);
}
}
}
}
}
*/