Total Palindrome Substring Cost
Given a lowercase string s, consider every substring s[l..r]. Define the cost of a substring as the minimum number of single-character replacements needed to make that substring a palindrome.
A replacement may change any character in the substring to any other lowercase letter. Return the sum of the costs over all substrings of s.
1Example 1
The substrings "ab", "bc", and "abc" each have cost 1. Single-character substrings have cost 0, so the total is 3.
2Example 2
A single-character string is already a palindrome.
3Example 3
The non-zero costs are "ab" = 1, "aab" = 1, "abb" = 1, and "aabb" = 2. The total is 5.
Constraints
Limits and guarantees your solution can rely on.
1 <= s.length <= 2 * 10^5scontains lowercase English letters.- The return value may exceed the 32-bit integer range.