Skip to main content
LeetCode 647, Medium. Topics: Two Pointers, String, Dynamic Programming. View on LeetCode. Generate this problem as a practice environment: tested reference solution, 15 parametrized pytest cases, and a playground notebook:

Problem

Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.

Examples

Constraints

1 <= s.length <= 1000 s consists of lowercase English letters.

Solution

Reference implementation from solution.py on GitHub, full suite in test_solution.py:

Complexity

Tags

Blind 75, NeetCode 150, NeetCode 250, NeetCode All.
Last modified on August 25, 2026