← Discussions on Count Palindromic Substrings
S sreddy
05 Jun 2026, 17:10

Asked in my Meesho OA last week.

Define dp[i] as the answer for the first i elements and write the transition from smaller states. Once it works, notice you only need the previous row/value, so space drops to O(1) or O(n).

1 reply

saiaga1 4 months, 1 week ago

You can avoid the extra array and do it in O(1) space.

Sign in to reply.