Skip to content

Files

Latest commit

 

History

History
28 lines (21 loc) · 2.14 KB

File metadata and controls

28 lines (21 loc) · 2.14 KB

Longest Palindromic Substring medium #javascript #blind75 #dynamic-programming #string

by Pawan Kumar @jsartisan

Take the Challenge

Given a string s, find the longest substring that is a palindrome.

Rules:

  • A palindrome reads the same forwards and backwards
  • If multiple palindromes have same length, return any one
  • String contains only letters and digits

Constraints:

  • 1 ≤ s.length ≤ 1000
  • s contains only digits and English letters

Examples:

// Example 1:
console.log(longestPalindrome("ababd"));
// Output: "bab"
// Explanation: "aba" would also be valid

// Example 2:
console.log(longestPalindrome("abbc"));
// Output: "bb"
// Explanation: Only palindrome of length 2

Back Share your Solutions Check out Solutions