|
| 1 | +<h2><a href="https://leetcode.com/problems/strange-printer-ii">Strange Printer II</a></h2> <img src='https://img.shields.io/badge/Difficulty-Hard-red' alt='Difficulty: Hard' /><hr><p>There is a strange printer with the following two special requirements:</p> |
| 2 | + |
| 3 | +<ul> |
| 4 | + <li>On each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.</li> |
| 5 | + <li>Once the printer has used a color for the above operation, <strong>the same color cannot be used again</strong>.</li> |
| 6 | +</ul> |
| 7 | + |
| 8 | +<p>You are given a <code>m x n</code> matrix <code>targetGrid</code>, where <code>targetGrid[row][col]</code> is the color in the position <code>(row, col)</code> of the grid.</p> |
| 9 | + |
| 10 | +<p>Return <code>true</code><em> if it is possible to print the matrix </em><code>targetGrid</code><em>,</em><em> otherwise, return </em><code>false</code>.</p> |
| 11 | + |
| 12 | +<p> </p> |
| 13 | +<p><strong class="example">Example 1:</strong></p> |
| 14 | +<img alt="" src="https://assets.leetcode.com/uploads/2021/12/23/print1.jpg" style="width: 600px; height: 175px;" /> |
| 15 | +<pre> |
| 16 | +<strong>Input:</strong> targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]] |
| 17 | +<strong>Output:</strong> true |
| 18 | +</pre> |
| 19 | + |
| 20 | +<p><strong class="example">Example 2:</strong></p> |
| 21 | +<img alt="" src="https://assets.leetcode.com/uploads/2021/12/23/print2.jpg" style="width: 600px; height: 367px;" /> |
| 22 | +<pre> |
| 23 | +<strong>Input:</strong> targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]] |
| 24 | +<strong>Output:</strong> true |
| 25 | +</pre> |
| 26 | + |
| 27 | +<p><strong class="example">Example 3:</strong></p> |
| 28 | + |
| 29 | +<pre> |
| 30 | +<strong>Input:</strong> targetGrid = [[1,2,1],[2,1,2],[1,2,1]] |
| 31 | +<strong>Output:</strong> false |
| 32 | +<strong>Explanation:</strong> It is impossible to form targetGrid because it is not allowed to print the same color in different turns. |
| 33 | +</pre> |
| 34 | + |
| 35 | +<p> </p> |
| 36 | +<p><strong>Constraints:</strong></p> |
| 37 | + |
| 38 | +<ul> |
| 39 | + <li><code>m == targetGrid.length</code></li> |
| 40 | + <li><code>n == targetGrid[i].length</code></li> |
| 41 | + <li><code>1 <= m, n <= 60</code></li> |
| 42 | + <li><code>1 <= targetGrid[row][col] <= 60</code></li> |
| 43 | +</ul> |
0 commit comments