Some data scientists are developing a tool to analyze palindromic trends in DNA sequences. The palindrome transformation cost of a string is defined as the minimum number of character changes required to rearrange it into a palindrome.For example, the palindrome transformation cost for the string "abcc" is 1 because changing the last character 'd' to 'C' makes the string "abcc", which can be rearranged into "acbc", a palindrome.
Given a string dna, determine the total sum of palindrome transformation costs for all its substrings.
Note A palindrome is a sequence that reads the same backward as forward, such as "z", "aba", and "a". Sequences like "y" and "rank" are not palindromes.
Hard