Longest Palindromic Substring
Given a string s, return its longest palindromic substring: the longest contiguous piece that reads the same from left to right as from right to left.
If several substrings share the longest length (for "babad", both "bab" and "aba"), return any one of them.
Constraints
1 <= s.length <= 1000sconsists of lowercase English letters.
Examples
Example 1
Input: s = "babad" Output: "bab"
Both "bab" and "aba" have length 3; either is accepted.
Example 2
Input: s = "cbbd" Output: "bb"
An even-length palindrome: "bb".
Example 3
Input: s = "a" Output: "a"
A single character is a palindrome.
JavaScript you'll use: Strings and characters
/**
* @param {string} s
* @return {string}
*/
function longestPalindrome(s) {
}
Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.