File tree
Expand file treeCollapse file tree1 file changed
+11
-0
lines changed Expand file treeCollapse file tree1 file changed
+11
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
|
| 1 | +var minimumRecolors = function(blocks, k) { |
| 2 | +let blackCount = 0, ans = blocks.length; |
| 3 | + |
| 4 | +for (let i = 0; i < blocks.length; i++) { |
| 5 | +if (i - k >= 0 && blocks[i - k] === 'B') blackCount--; |
| 6 | +if (blocks[i] === 'B') blackCount++; |
| 7 | +ans = Math.min(ans, k - blackCount); |
| 8 | +} |
| 9 | + |
| 10 | +return ans; |
| 11 | +}; |
You can’t perform that action at this time.
0 commit comments