Please read the new rule regarding the restriction on the use of AI tools. ×

A problem with Strings

Revision en1, by priyanshbarya, 2023-11-04 22:32:37

Problem: Let us define the cost of string s to be the number of characters to be replaced such that the resulting string is rearrangeable to palindrome.

For e.g., let s="abc", the cost is 1 since we can change b to a (or b to c), and the resulting string will be rearrangeable to a palindrome.

You are given a string s (1<=length<=1e5). Find the sum of the cost of all the substrings.

Please help me out with this problem.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English priyanshbarya 2023-11-04 22:32:37 470 Initial revision (published)