Here is the interview question prompt, presented for reference.
We have a string str
like the following:
const str = "bubble";
Find a way to convert it to a palindrome by inserting characters in front of it. Recall that a palindrome
is defined as "a word, phrase, or sequence that reads the same backward as forward".
What's the shortest palindrome that can be returned? For example, the following above string should return:
shortestPalindrome("bubble")
// "elbbubble"
1000
O(n)
O(1)
You can see the full challenge with visuals at this link.
Challenges • Asked almost 7 years ago by Jake from AlgoDaily
This is the main discussion thread generated for Find Shortest Palindrome Possible.
The question said:
> Expected time complexity : O(n)
but the solution said:
> The time complexity is O(n2)
I believe the question is incorrect.