Count Palindromic Substrings Problem Statement

Given a string STR, determine the total number of palindromic substrings within STR.

Input:

The first line contains an integer 't' representing the number of test cases. For each test case, provide the string STR for counting palindromic substrings.

Output:

For each test case, return a single integer denoting the total count of palindromic substrings.

Example:

Input:
"t" = 1
STR = "abbc"
Output:
5
Explanation:

The palindromic substrings are: ["a", "b", "b", "c", "bb"]. Therefore, the output is 5.

Constraints:

  • 1 <= t <= 100
  • 0 <= N <= 1000

Here, t is the number of test cases, and N is the length of the string. Time Limit: 1 sec.

Note:

A 'Palindrome' reads the same forward and backward, such as "abba". A 'Substring' is a continuous sequence within a string, like "a", "b", and "abc" in "abc". Function implementation only required, output management is handled externally.
AnswerBot
4mo

Count the total number of palindromic substrings in a given string.

  • Iterate through each character in the string and expand around it to find palindromic substrings.

  • Use dynamic programming to store pre...read more

Help your peers!
Select
Add answer anonymously...

Cadence Design Systems Software Developer interview questions & answers

A Software Developer was asked 6mo agoQ. Given an array, reverse the order of its elements in place.
A Software Developer was asked Q. Given the coordinates of a point and a rectangle, how would you determine if the...read more
A Software Developer was asked Q. You are given an array of elements. Some or all of them are duplicates. Find the...read more

Popular interview questions of Software Developer

A Software Developer was asked 6mo agoQ1. Given an array, reverse the order of its elements in place.
A Software Developer was asked Q2. Given the coordinates of a point and a rectangle, how would you determine if the...read more
A Software Developer was asked Q3. You are given an array of elements. Some or all of them are duplicates. Find the...read more
Cadence Design Systems Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits