Problem · String
Palindromic Substrings (LC 647 :)
Learn this problemProblem statement
Given a string s, return the number of palindromic substrings in it.
A string is a palindrome when it reads the same backward as forward.
A substring is a contiguous sequence of characters within the string.
Function
countSubstrings(s: String) → intExamples
Example 1
s = "abc"return = 3Three palindromic strings: "a", "b", "c".
Example 2
s = "aaa"return = 6Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".
Constraints
1 <= s.length <= 1000sconsists of lowercase English letters.
More Citadel problems
- Minimum Changes for a Periodic PalindromeOA · Seen Jul 2026
- Minimum Image Processing CostOA · Seen Jul 2026
- Minimum Path Sum to Target in Binary TreePHONE SCREEN · Seen Apr 2026
- Minimum Time to Process RequestsOA · Seen Mar 2026
- Process SchedulingOA · Seen Mar 2026
- Social Media SuggestionsSeen May 2025
- Best Sum Downward Tree PathSeen May 2025
- Price CheckSeen Feb 2025