Practice Strange Printer II
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
Starting with a blank grid, each print operation paints a solid rectangle in one color, overwriting any previous colors in that rectangle. Each color may be used for only one operation. Return whether some sequence of operations can produce targetGrid exactly.
Source: Strange Printer II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
Output
true
# Example 2
Input
targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
Output
true
# Example 3
Input
targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
Output
false
Constraints
m == targetGrid.length
n == targetGrid[i].length
1 <= m, n <= 60
1 <= targetGrid[row][col] <= 60
Related LeetCode Problems
Practice more problems similar to Strange Printer II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.