223. Count Palindromic Substrings

MediumStringString

Given a string s, return the number of palindromic substrings (each occurrence counted separately, including single characters).

Input: A quoted string s.

Output: Integer — count of palindromic substrings.

Examples

Example 1
Input: "abc"
Output: 3
Explanation: 'a','b','c'.
Example 2
Input: "aaa"
Output: 6
Explanation: 3 singles, 2 doubles, 1 triple.
Example 3
Input: "aba"
Output: 4
Explanation: 'a','b','a','aba'.

Constraints

Asked by

AmazonMicrosoftGoogleAdobeFlipkart
Solve this problem in the editor →