# 647. Palindromic Substrings

Reference: LeetCode
Difficulty: Medium

## Problem

Given a string, your task is to count how many palindromic substrings in this string.

The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.

Note: The input string length won’t exceed 1000.

Example:

## Analysis

### Brute-Force

Time: $O(N^3)$
Space: $O(1)$

### Expansion From the Center

Time: $O(N^2)$
Space: $O(1)$

### DP (marked)

Based on the idea in 5. Longest Palindrome Substring we can use dynamic programming to solve this problem.

Time: $O(N^2)$
Space: $O(N^2)$

Comment
Junhao Wang
a software engineering cat