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

priyanshbarya's blog

By priyanshbarya, history, 11 months ago, In English

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.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it