Practice Check if Grid can be Cut into Sections
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
An n by n grid contains nonoverlapping rectangles [startX, startY, endX, endY], specified by bottom-left and top-right corners. Decide whether two horizontal cuts or two vertical cuts can divide the grid into three sections, each containing at least one whole rectangle, with every rectangle entirely in exactly one section. Cuts may lie along rectangle boundaries but cannot split rectangle interiors. Return whether such cuts exist.
Source: Check if Grid can be Cut into Sections on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 5, rectangles = [[1,0,5,2],[0,2,2,4],[3,2,5,3],[0,4,4,5]]
true
# Example 2
n = 4, rectangles = [[0,0,1,1],[2,0,3,4],[0,2,2,3],[3,0,4,3]]
true
# Example 3
n = 4, rectangles = [[0,2,2,4],[1,0,3,2],[2,2,3,4],[3,0,4,2],[3,2,4,4]]
false
Constraints
Related LeetCode Problems
Practice more problems similar to Check if Grid can be Cut into Sections.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.