Problem · String
Set Total Palindrome Transformation Cost
Learn this problemProblem statement
A string is called "palindrome-like" if it can be rearranged in any way to become a palindrome.
For example, aabb is palindrome-like since it can be rearranged to abba.
For any string, you are allowed to change any number of characters to make it palindrome-like.
Let this minimum number of changes be the string's cost.
Given a string s, find the total sum of palindrome transformation costs of all substrings of s.
Also asked by Google: DNA Sequencing.
Function
setTotalPalindromeTransformationCost(s: String) → longExamples
Example 1
s = "abca"return = 6The substrings of "abca" with non-zero cost are "ab", "abc", "abca", "bc", "bca", and "ca". Each costs 1, while single-character substrings cost 0.
The total cost is therefore 6.
Constraints
1 <= n <= 10^5sconsists of lowercase English letters
More Intuit problems
- Small Business Network: Degrees of SeparationPHONE SCREEN · Seen May 2026
- Smart Gardener (Intuit India)OA · Seen Feb 2024
- Jumping Kady (Intuit India)OA · Seen Feb 2024
- Longest Cipher (Intuit India)OA · Seen Feb 2024
- Maximum Reward (Intuit India)OA · Seen Feb 2024
- Spreading Fire (Intuit India)OA · Seen Feb 2024
- Virus Spread (Intuit India)OA · Seen Feb 2024
- Ice Cream SticksOA · Seen Feb 2024