1591. Strange Printer II Hard
1/**
2 * [1591] Strange Printer II
3 *
4 * There is a strange printer with the following two special requirements:
5 *
6 * 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.
7 * Once the printer has used a color for the above operation, the same color cannot be used again.
8 *
9 * You are given a m x n matrix targetGrid, where targetGrid[row][col] is the color in the position (row, col) of the grid.
10 * Return true if it is possible to print the matrix targetGrid, otherwise, return false.
11 *
12 * Example 1:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2021/12/23/print1.jpg" style="width: 600px; height: 175px;" />
14 * Input: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]
15 * Output: true
16 *
17 * Example 2:
18 * <img alt="" src="https://assets.leetcode.com/uploads/2021/12/23/print2.jpg" style="width: 600px; height: 367px;" />
19 * Input: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]
20 * Output: true
21 *
22 * Example 3:
23 *
24 * Input: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]
25 * Output: false
26 * Explanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.
27 *
28 *
29 * Constraints:
30 *
31 * m == targetGrid.length
32 * n == targetGrid[i].length
33 * 1 <= m, n <= 60
34 * 1 <= targetGrid[row][col] <= 60
35 *
36 */
37pub struct Solution {}
38
39// problem: https://leetcode.com/problems/strange-printer-ii/
40// discuss: https://leetcode.com/problems/strange-printer-ii/discuss/?currentPage=1&orderBy=most_votes&query=
41
42// submission codes start here
43
44impl Solution {
45 pub fn is_printable(target_grid: Vec<Vec<i32>>) -> bool {
46 false
47 }
48}
49
50// submission codes end
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_1591() {
58 }
59}
60
Back
© 2025 bowen.ge All Rights Reserved.