Minimum Recolor Window

You are given a string blocks where each character is 'W' (white) or 'B' (black). In one operation, you can recolor a white block to black.

Return the minimum number of recolorings needed so that the string contains at least k consecutive black blocks.

If it is impossible, return -1.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 420 60" width="420" height="60" fill="none"> <rect width="420" height="60" fill="#f8f9fa" rx="4"/> <text x="12" y="38" font-family="monospace" font-size="22" fill="#333">W B W</text> <text x="86" y="38" font-family="monospace" font-size="22" fill="#e63946" font-weight="bold">B B B</text> <text x="185" y="38" font-family="monospace" font-size="22" fill="#333">W</text> <text x="12" y="55" font-family="monospace" font-size="11" fill="#888">blocks = "WBWBBB" → recolor W→B at pos 0, k = 4</text> </svg>
Examples
Input: ["WBWBBBW",7]
Output: 3
Hints

Minimum Recolor Window

You are given a string `blocks` where each character is `'W'` (white) or `'B'` (black). In one operation, you can recolor a white block to black.