2484. Count Palindromic Subsequences

Hard DP One-pass

Target String: "10301"

Get Ready

Click "Next Step" to begin processing the string. We'll observe how each digit updates the palindromic subsequence counts in reverse order (DP5 to DP1).

DP State Visualization

DP5 (Length 5) "abcba"
Total: 0
DP4 (Length 4) "abcb"
DP3 (Length 3) "abc"
DP2 (Length 2) "ab"
DP1 (Length 1) "a"
Implementation