Community

Start a Thread


Notifications
Subscribe You’re not receiving notifications from this thread.

Longest Palindromic Substring (Main Thread)

Here is the interview question prompt, presented for reference.

We're given a string that's a mixture of several alphabetical characters.

const str = "algototheehtotdaily";

Could you write a method to find the longest substring that is considered a palindrome? In the above example, it would be "totheehtot".

Where there are multiple longest palindromic substrings of the same length, for example in "abracadabra" ("aca" and "ada"), return the first to appear.

Constraints

  • The string can be empty, in which case return an empty string
  • The string will consist of only lowercase alphabets
  • Expected time complexity : O(n^2)
  • Expected space complexity : O(n^2)

You can see the full challenge with visuals at this link.

Challenges • Asked almost 7 years ago by Jake from AlgoDaily

Jake from AlgoDaily Commented on Nov 30, 2017:

This is the main discussion thread generated for Longest Palindromic Substring.