Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Distinct Palindromic Subsequences > Editorial

Distinct Palindromic Subsequences — Solution & Editorial

Back to the Problem

Interval DP: when the endpoints match, dp[i][j] = 2·dp[i+1][j−1] + 2 (the +2 for the two-character and single-character palindromes of that pair); otherwise inclusion–exclusion over dropping an end.

Complexity: O(|S|2)

Watch out: The matching-ends case double-counts inner palindromes plus the new pair; the subtraction case removes the overlap dp[i+1][j−1].