Tap here to switch tabs
Problem
Submissions

Problem: Maximum White Tiles Covered by a Carpet

med
30 min
Try to solve the Maximum White Tiles Covered by a Carpet problem.

Statement

You are given a two dimensional integer array tiles, where tiles[i] =[li,ri]= [l_i, r_i] indicates that each tile from lil_i to rir_i inclusive is colored white. You are also given an integer carpetLen, representing the length of a carpet that can be positioned anywhere on the line.

Return the maximum number of white tiles that can be covered by the carpet.

Constraints:

  • 1≤1 \leq tiles.length ≤5imes104\leq 5 imes 10^4

  • tiles[i].length =2= 2

  • 1≤li≤ri≤1091 \leq l_i \leq r_i \leq 10^9

  • 1≤1 \leq carpetLen ≤109\leq 10^9

  • The tiles are non overlapping.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum White Tiles Covered by a Carpet

med
30 min
Try to solve the Maximum White Tiles Covered by a Carpet problem.

Statement

You are given a two dimensional integer array tiles, where tiles[i] =[li,ri]= [l_i, r_i] indicates that each tile from lil_i to rir_i inclusive is colored white. You are also given an integer carpetLen, representing the length of a carpet that can be positioned anywhere on the line.

Return the maximum number of white tiles that can be covered by the carpet.

Constraints:

  • 1≤1 \leq tiles.length ≤5imes104\leq 5 imes 10^4

  • tiles[i].length =2= 2

  • 1≤li≤ri≤1091 \leq l_i \leq r_i \leq 10^9

  • 1≤1 \leq carpetLen ≤109\leq 10^9

  • The tiles are non overlapping.