A TikTok participant is engaging in a challenge where they have a binary string representing a sequence of dance moves. The string consists of 0s
and 1s
, with 0s
signifying pauses and 1s
representing dance moves.
The participant can choose exactly k
distinct positions in the string to modify. These modifications involve flipping the moves at those positions, converting 0s
to 1s
and 1s
to 0s
.
The objective is to maximize the count of pairs of consecutive dance moves (1s) in the final dance sequence. In TikTok challenges, participants aim to create the smoothest dance transitions.
Your task is to assist the participant in determining the maximum possible number of pairs of consecutive dance moves (1s)
in the final dance sequence after the allowable adjustments.
Note that the count of pairs of consecutive 1s
represents the number of indices i
(1 ≤ i
< n
) where s[i]
= '1' and s[i+1]
= '1', showcasing the seamless dance transitions in the challenge.
Example 1:
Input: s = "01010", k = 2
Output: 3
Explanation:Following are some possible selection of positions ins
:If we choose 1st and 3rd indices, then we get the resulting string as "11110" having 3 pairs of consecutive 1s, which is the maximum possible. Hence, the answer is 3.
Unkwnon for now 🐸

input:
output: