Count distinct palindromes

Write codeHard35 min

Your task

Given a lowercase string s, count the number of DISTINCT non-empty palindromic substrings (distinct by string content, not by position). For 'aaa' the answer is 2 ('a' and 'aa' and 'aaa' are 3 distinct). For 'abba' the distinct palindromes are 'a','b','bb','abba' = 4. Return that count. Length up to ~2000.

Examples

count_distinct_palindromes(s: str) -> int
Example 1
Inputcount_distinct_palindromes("abba")
Output4