Longest Substring that is a Palindrome
https://leetcode.com/problems/longest-palindromic-substring/submissions/
I managed to get the brute force quite quickly. Double iteration getting all the substrings. Greedily add them if longer than current longest substring.
How to make a more efficient solution... that is the question!
I quite like this recursive helper function I used for string reversal:
function reverseString(str) {
if (str === ""){
return "";}
else{
return reverseString(str.substr(1)) + str.charAt(0);}
}
Top comments (0)