DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
String

Count Palindromic Substrings

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Count Palindromic Substrings** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Expand around center, count each palindrome **Edge Cases to Consider:** - (1) Single character - (2) All same characters (n(n+1)/2) - (3) No palindromes > length 1

Examples

Example 1
Input: "abc"
Output: 3
Explanation: "a","b","c"
Example 2
Input: "aaa"
Output: 6
Explanation: "a","a","a","aa","aa","aaa"
Example 3
Input: "a"
Output: 1
Explanation: Single

Constraints

  • ▪1 <= s.length <= 10^4
  • ▪s consists of printable ASCII characters
  • ▪Solve with optimal space complexity

Watch Out For Edge Cases

  • ▪Single character
  • ▪All same characters (n(n+1)/2)
  • ▪No palindromes > length 1
Frequently Asked At
AmazonGoogleMicrosoftMeta