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
.
Access this course and 1400+ top-rated courses and projects.