InterviewBit Academy is now Scaler!
InterviewBit Academy is now Scaler Academy!

Palindromic Substrings Count

Given a string Aconsisting of lowercase English alphabets. Your task is to find how many substrings of A are palindrome.

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

Return the count of palindromic substrings.

Note: A string is palindrome if it reads the same from backward and forward.

Input Format

The only argument given is string A.

Output Format

Return the count of palindromic substrings.


1 <= length of the array <= 1000

For Example

Input 1:
    A = "abab"
Output 1:
    Explanation 1:
        6 palindromic substrings are:
        "a", "aba", "b", "bab", "a" and "b".

Input 2:
    A = "ababa"
Output 2:
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving  Palindromic Substrings Count on Interview Code Editor
Sign Up
to access hints and editorial solutions for Palindromic Substrings Count


Click here to start solving coding interview questions