Count all palindromic substrings
ReevoSoftware Engineer · Online AssessmentLast updated
This question evaluates proficiency with string algorithms and algorithmic problem-solving, focusing on palindrome detection and counting contiguous substrings. It is commonly asked to assess implementation skills and the ability to reason about time and space complexity within the Coding & Algorithms domain, emphasizing practical application rather than purely conceptual understanding.
Given a string s, count how many substrings of s are palindromes.
- A substring is a contiguous block of characters.
- A palindrome reads the same forward and backward.
- Count all palindromic substrings (including duplicates by position).
Return the total count.
Constraints (typical): 1 ≤ |s| ≤ 2000 (so an O(n^2) approach is acceptable).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.