DIY: Palindromic Substrings
Solve the interview question "Palindromic Substrings" in this lesson.
We'll cover the following
Problem Statement
Given a string s
, your task is to implement the algorithm that will return the number of palindromic substrings in it.
Note: A string is a palindrome when it reads the same backward as forward, and a substring is a contiguous sequence of characters within the string.
Consider the string "abb"
. The substrings of "abb"
are "a"
, "b"
, "b"
, and "bb"
. Of these, all four are palindromes, so the algorithm should return 4
.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.