Hard · Tries
Find Distinct Palindromic Substrings
Given a string s of lowercase letters, return the number of distinct non-empty substrings of s that are palindromes; each different string counts once, however often it occurs.
Examples
Example 1
s = "aba"Output: 3 distinct palindromes
Example 2
s = "aabb"Output: 4 distinct palindromes
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.