Skip to content

Practice Palindromic Substrings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#647
LeetCode Problem

Palindromic Substrings

Problem Statement

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.

Source: Palindromic Substrings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "abc"
Output
3

# Example 2

Input
s = "aaa"
Output
6

Constraints

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

Related LeetCode Problems

Practice more problems similar to Palindromic Substrings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.