Company: Cashfree_6nov
Difficulty: medium
DNA Sequencing Problem Description 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 of the string "abbc" is 1 because changing the first character 'a' to 'b' makes the string "bbbc", which can be rearranged into "bccb", 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, e.g., 'aba', 'madam', and 'level'. Sequences like 'xy' and 'rank' are not palindromes. Examples Example 1: Input: dna = "abca" Output: 6 Explanation: Suppose dna = "abca", substrings of dna with their costs are: "a", "b", "c", "a", with cost = 0 "ab", cost = 1, we can change 'b' to 'a' and it becomes "aa" which is a palindrome. "abc", cost = 1, we can