Longest Palindromic Subsequence

Given a string s, find the length of the longest palindromic subsequence in s. A subsequence is a sequence derived from another sequence by deleting some elements without changing the order of the remaining elements.

Constraints

  • 1 <= s.length <= 1000
  • s consists only of lowercase English letters.
Saving… · 2 lines
class Solution:
def longestPalindromicSubsequence(self, s: str) -> int:
Console

Click Run to execute sample tests.