Problem · String
Palindromic Substrings
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 Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026