Mark As Completed Discussion

Good afternoon! Here's our prompt for today.

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

JAVASCRIPT
1const 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.

Description

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)

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's our guided, illustrated walk-through.

How do I use this guide?