Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
