Tap here to switch tabs
Problem
Submissions

Problem: Minimum White Tiles After Covering With Carpets

med
30 min
Try to solve the Minimum White Tiles After Covering With Carpets problem.

Statement

You are given a binary string floor representing the colors of tiles along a floor, where floor[i] = ′1′'1' indicates that the tile at index i is white, and floor[i] = ′0′'0' indicates that the tile at index i is black.

You are also given two integers numCarpets and carpetLen. You have numCarpets black carpets, each of length carpetLen tiles. Each carpet can cover carpetLen consecutive tiles on the floor.

Return the minimum number of white tiles that remain visible after optimally placing the carpets.

Note: Carpets are permitted to overlap with each other.

Constraints:

  • 1≤1 \leq carpetLen ≤\leq floor.length ≤1000\leq 1000

  • floor[i] is either ′0′'0' or ′1′'1'.

  • 1≤1 \leq numCarpets ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum White Tiles After Covering With Carpets

med
30 min
Try to solve the Minimum White Tiles After Covering With Carpets problem.

Statement

You are given a binary string floor representing the colors of tiles along a floor, where floor[i] = ′1′'1' indicates that the tile at index i is white, and floor[i] = ′0′'0' indicates that the tile at index i is black.

You are also given two integers numCarpets and carpetLen. You have numCarpets black carpets, each of length carpetLen tiles. Each carpet can cover carpetLen consecutive tiles on the floor.

Return the minimum number of white tiles that remain visible after optimally placing the carpets.

Note: Carpets are permitted to overlap with each other.

Constraints:

  • 1≤1 \leq carpetLen ≤\leq floor.length ≤1000\leq 1000

  • floor[i] is either ′0′'0' or ′1′'1'.

  • 1≤1 \leq numCarpets ≤1000\leq 1000