-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path542.01-matrix.cpp
More file actions
58 lines (55 loc) · 1007 Bytes
/
542.01-matrix.cpp
File metadata and controls
58 lines (55 loc) · 1007 Bytes
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
/*
* @lc app=leetcode id=542 lang=cpp
*
* [542] 01 Matrix
*
* https://leetcode.com/problems/01-matrix/description/
*
* algorithms
* Medium (43.88%)
* Likes: 5848
* Dislikes: 291
* Total Accepted: 317.7K
* Total Submissions: 719.8K
* Testcase Example: '[[0,0,0],[0,1,0],[0,0,0]]'
*
* Given an m x n binary matrix mat, return the distance of the nearest 0 for
* each cell.
*
* The distance between two adjacent cells is 1.
*
*
* Example 1:
*
*
* Input: mat = [[0,0,0],[0,1,0],[0,0,0]]
* Output: [[0,0,0],[0,1,0],[0,0,0]]
*
*
* Example 2:
*
*
* Input: mat = [[0,0,0],[0,1,0],[1,1,1]]
* Output: [[0,0,0],[0,1,0],[1,2,1]]
*
*
*
* Constraints:
*
*
* m == mat.length
* n == mat[i].length
* 1 <= m, n <= 10^4
* 1 <= m * n <= 10^4
* mat[i][j] is either 0 or 1.
* There is at least one 0 in mat.
*
*
*/
// @lc code=start
class Solution {
public:
vector<vector<int>> updateMatrix(vector<vector<int>>& mat) {
}
};
// @lc code=end