Longest Palindromic Substring in javascript
Hello friends, If you come here to check the solution of the following question. Longest Palindromic Substring in javascript this question is asked in LeetCode as a Longest Palindromic Substring (Question Number -5) and its difficulty is medium. So let's first understand the question. Given a string s , return the longest palindromic substring in s . Example 1: Input: s = "babad" Output: "bab" Explanation: "aba" is also a valid answer. Example 2: Input: s = "cbbd" Output: "bb" Constraints: 1 <= s.length <= 1000 s consist of only digits and English letters. So the solution to the above question is. /** * @param {string} s * @return {boolean} */ var longestPalindrome = function(s) { let startIndex = 0; let maxLength = 1; function expandMiddle(left, right) { while (left >= 0 && right < s.length && s[left] === s[right]) { const currentPalindromeLength = ri...