[Solution] Black and White Stripe Codeforces Solution
You have a stripe of checkered paper of length . Each cell is either white or black.
What is the minimum number of cells that must be recolored from white to black in order to have a segment of consecutive black cells on the stripe?
If the input data is such that a segment of consecutive black cells already exists, then print 0.
The first line contains an integer () — the number of test cases.
Solution Click Below:- CLICK HERE
Next, descriptions of test cases follow.
The first line of the input contains two integers and (). The second line consists of the letters 'W' (white) and 'B' (black). The line length is .
It is guaranteed that the sum of values does not exceed .
For each of test cases print an integer — the minimum number of cells that need to be repainted from white to black in order to have a segment of consecutive black cells.
No comments:
Post a Comment