βLongest Palindromic Substring
Brute Force
Time Complexity:
Where isPalindrome(str) takes β time and generating all the substrings take β time.
Space Complexity: β for the result.
Efficient Solution
Time Complexity: β
Space Complexity: β for the result
Logic: Assume each letter as a centre of a palindrome and expand outward while checking if it is a palindrome.
Edge Case: Even Length palindrome.
Last updated