Skip to content

Practice Minimum White Tiles After Covering With Carpets

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2209
LeetCode Problem

Minimum White Tiles After Covering With Carpets

Problem Statement

The string floor describes a row of tiles: 0 is black and 1 is white. You have numCarpets black carpets, each covering carpetLen consecutive tiles. Place them to minimize the white tiles left visible; carpets may overlap. Return that minimum number of uncovered white tiles.

Source: Minimum White Tiles After Covering With Carpets on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
floor = "10110101", numCarpets = 2, carpetLen = 2
Output
2

# Example 2

Input
floor = "11111", numCarpets = 2, carpetLen = 3
Output
0

Constraints

1 <= carpetLen <= floor.length <= 1000
floor[i] is either '0' or '1'.
1 <= numCarpets <= 1000

Related LeetCode Problems

Practice more problems similar to Minimum White Tiles After Covering With Carpets.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.