Question
Palindromic Rearrangement Substrings
You are given a string
A substring is called valid if its characters can be rearranged to form a palindrome.
For example,
Your task is to count the number of non-empty valid substrings of
Input
The first line contains a single integer KaTeX can only parse string typed expression — the length of the string.
The second line contains a string KaTeX can only parse string typed expression of length KaTeX can only parse string typed expression.
Output
Print a single integer — the number of non-empty substrings whose characters can be rearranged to form a palindrome.
Example
Example 1:
Input
The substrings are:
So, there are KaTeX can only parse string typed expression valid substrings.
Input
3
aabOutput5ExplanationThe substrings are:
a → valida → validb → validaa → validab → not validaab → validSo, there are KaTeX can only parse string typed expression valid substrings.