Tap here to switch tabs
Problem
Submissions

Problem: Longest Palindromic Subsequence II

Try to solve the Longest Palindromic Subsequence II problem.

Statement

Given a string s, return the length of the longest good palindromic subsequence in s.

A string is considered a good palindromic subsequence if:

  • It is a subsequence of s.

  • It is a palindrome.

  • Its length is an even number.

  • No two consecutive characters are identical, except for the two middle characters (that is, for a string of length kk, the character at index ii does not equal the character at index i+1i + 1 for all 0≤i<k2−10 \leq i < \frac{k}{2} - 1).

Note: A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

Constraints:

  • 1≤1 \leq s.length ≤250\leq 250

  • s consists of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Palindromic Subsequence II

Try to solve the Longest Palindromic Subsequence II problem.

Statement

Given a string s, return the length of the longest good palindromic subsequence in s.

A string is considered a good palindromic subsequence if:

  • It is a subsequence of s.

  • It is a palindrome.

  • Its length is an even number.

  • No two consecutive characters are identical, except for the two middle characters (that is, for a string of length kk, the character at index ii does not equal the character at index i+1i + 1 for all 0≤i<k2−10 \leq i < \frac{k}{2} - 1).

Note: A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

Constraints:

  • 1≤1 \leq s.length ≤250\leq 250

  • s consists of lowercase English letters.