Longest Palindromic Subsequence
Given a string s, find the longest palindromic subsequence's length in s. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
Longest Palindromic Subsequence

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

Example 1:
Input: "bbbab"
Output: 4
Input
arr ="bbbab"

Initialize DP table

b
b
b
a
b
DP Table (dp[i][j] = LPS length for s[i..j])
b
b
b
a
b
b
0
0
0
0
0
b
-
0
0
0
0
b
-
-
0
0
0
a
-
-
-
0
0
b
-
-
-
-
0
Variables
No variables to display
DepthFunction Call
Stack empty
0/12