0 out of 464 challenges solved

Longest Palindromic Subsequence

Write a function `longest_palindromic_subsequence(s: str) -> int` that takes a string `s` as input and returns the length of the longest palindromic subsequence in the string. A subsequence is a sequence derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

#### Example Usage
```python [main.nopy]
print(longest_palindromic_subsequence("bbbab"))  # Output: 4
print(longest_palindromic_subsequence("cbbd"))   # Output: 2
```

#### Constraints
- The input string will only contain lowercase English letters.
- The length of the string will be between 1 and 1000.
def longest_palindromic_subsequence(s: str) -> int:
    """
    Calculate the length of the longest palindromic subsequence in the given string.

    Args:
    s (str): The input string.

    Returns:
    int: The length of the longest palindromic subsequence.
    """
    # Placeholder for the solution
    pass