← Count Palindromic Substrings
Discussions
Sign in to join the discussion.
S
sreddy
OFFICIAL
2 months, 2 weeks ago
Clean C++ solution, beats most submissions.
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
S
sreddy
4 months, 1 week ago
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