-
Notifications
You must be signed in to change notification settings - Fork 0
/
1034.边框着色.c
75 lines (68 loc) · 1.99 KB
/
1034.边框着色.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* @lc app=leetcode.cn id=1034 lang=c
*
* [1034] 边框着色
*
* https://leetcode-cn.com/problems/coloring-a-border/description/
*
* algorithms
* Medium (42.55%)
* Likes: 16
* Dislikes: 0
* Total Accepted: 2.3K
* Total Submissions: 5.4K
* Testcase Example: '[[1,1],[1,2]]\n0\n0\n3'
*
* 给出一个二维整数网格 grid,网格中的每个值表示该位置处的网格块的颜色。
*
* 只有当两个网格块的颜色相同,而且在四个方向中任意一个方向上相邻时,它们属于同一连通分量。
*
* 连通分量的边界是指连通分量中的所有与不在分量中的正方形相邻(四个方向上)的所有正方形,或者在网格的边界上(第一行/列或最后一行/列)的所有正方形。
*
* 给出位于 (r0, c0) 的网格块和颜色 color,使用指定颜色 color 为所给网格块的连通分量的边界进行着色,并返回最终的网格 grid
* 。
*
*
*
* 示例 1:
*
* 输入:grid = [[1,1],[1,2]], r0 = 0, c0 = 0, color = 3
* 输出:[[3, 3], [3, 2]]
*
*
* 示例 2:
*
* 输入:grid = [[1,2,2],[2,3,2]], r0 = 0, c0 = 1, color = 3
* 输出:[[1, 3, 3], [2, 3, 3]]
*
*
* 示例 3:
*
* 输入:grid = [[1,1,1],[1,1,1],[1,1,1]], r0 = 1, c0 = 1, color = 2
* 输出:[[2, 2, 2], [2, 1, 2], [2, 2, 2]]
*
*
*
* 提示:
*
*
* 1 <= grid.length <= 50
* 1 <= grid[0].length <= 50
* 1 <= grid[i][j] <= 1000
* 0 <= r0 < grid.length
* 0 <= c0 < grid[0].length
* 1 <= color <= 1000
*
*
*
*
*/
// @lc code=start
/**
* Return an array of arrays of size *returnSize.
* The sizes of the arrays are returned as *returnColumnSizes array.
* Note: Both returned array and *columnSizes array must be malloced, assume caller calls free().
*/
int** colorBorder(int** grid, int gridSize, int* gridColSize, int r0, int c0, int color, int* returnSize, int** returnColumnSizes){
}
// @lc code=end