Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя priyanshbarya

Автор priyanshbarya, история, 11 месяцев назад, По-английски

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.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится