Tap here to switch tabs
Problem
Submissions

Problem: Check if Grid can be Cut into Sections

med
30 min
Try to solve the Check if Grid can be Cut into Sections problem.

Statement

You are given an integer n representing the dimensions of an n $ imes$ n grid, and a 22D integer array rectangles where rectangles[i] = [start_x, start_y, end_x, end_y] denotes a rectangle on the grid.

A cut is a horizontal or vertical line spanning entirely across the grid. A cut is valid if it does not intersect the interior of any rectangle, though it may touch a rectangle along its edges.

Return true if it is possible to make either 22 horizontal cuts or 22 vertical cuts such that the grid is divided into at least 33 non empty sections, where each section contains at least 11 rectangle. Otherwise, return false.

Constraints:

  • 3≤3 \leq n ≤109\leq 10^9

  • 3≤3 \leq rectangles.length ≤105\leq 10^5

  • 0≤0 \leq rectangles[i][0] << rectangles[i][2] ≤\leq n

  • 0≤0 \leq rectangles[i][1] << rectangles[i][3] ≤\leq n

  • No two rectangles overlap.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Check if Grid can be Cut into Sections

med
30 min
Try to solve the Check if Grid can be Cut into Sections problem.

Statement

You are given an integer n representing the dimensions of an n $ imes$ n grid, and a 22D integer array rectangles where rectangles[i] = [start_x, start_y, end_x, end_y] denotes a rectangle on the grid.

A cut is a horizontal or vertical line spanning entirely across the grid. A cut is valid if it does not intersect the interior of any rectangle, though it may touch a rectangle along its edges.

Return true if it is possible to make either 22 horizontal cuts or 22 vertical cuts such that the grid is divided into at least 33 non empty sections, where each section contains at least 11 rectangle. Otherwise, return false.

Constraints:

  • 3≤3 \leq n ≤109\leq 10^9

  • 3≤3 \leq rectangles.length ≤105\leq 10^5

  • 0≤0 \leq rectangles[i][0] << rectangles[i][2] ≤\leq n

  • 0≤0 \leq rectangles[i][1] << rectangles[i][3] ≤\leq n

  • No two rectangles overlap.