Problem · String

Palindromic Substrings (LC 647 :)

Learn this problem
EasyCitadelNEW GRADOA

Problem 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) → int

Examples

Example 1

s = "abc"return = 3

Three palindromic strings: "a", "b", "c".

Example 2

s = "aaa"return = 6

Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa".

Constraints

  • 1 <= s.length <= 1000
  • s consists of lowercase English letters.

More Citadel problems

drafts saved locally
public int countSubstrings(String s) {
  // write your code here
}
s"abc"
expected3
checking account