Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem statement Send feedback You are given a string ' S ' of length ' N ' and an integer ' K ' . '
Problem statement
Send feedback
You are given a string of length and an integer is a divisor of
Suppose you break the string into subarrays where K ie
The first substring is dotsK
The second substring is dots
The th substring is is :
You are allowed to do the following operation:
Choose any index i of the string S
Replace it with any lowercase character. The cost of this operation is :
Your task is to convert the string such that:
All the characters in a substring are same for each of the substrings.
Any two consecutive substrings do not have the same character.
Your task is to find the minimum cost to do so and return it
Note:
For a string denotes the string S substring from index to index j
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started