Given a string s of lowercase English letters, return the number of distinct non-empty substrings of s that are palindromes.
A substring is a contiguous part of s. A palindrome reads the same forwards and backwards. A palindrome that occurs at several positions in s is counted once.
Examples
Example 1
Input: s = "aabaa"
Output: 5
Explanation: The distinct palindromic substrings are "a", "b", "aa", "aba", and "aabaa".
"aa" occurs twice and "a" occurs four times, but each is counted once.
Example 2
Input: s = "abc"
Output: 3
Explanation: Only the single letters "a", "b", and "c" are palindromes.
Constraints
1≤s.length≤105
s consists of lowercase English letters.
Loading editor...
Run checks the sample cases; Submit runs every case.
Samples 2
Custom 0
passedwrong answertime limiterrorran, no expected valuenot run