最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

LeetCode 542. 01 Matrix

2023-04-28 12:23 作者:您是打尖兒還是住店呢  | 我要投稿

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 <= 104

  • 1 <= m * n <= 104

  • mat[i][j]?is either?0?or?1.

  • There is at least one?0?in?mat.

BFS計(jì)算,算是經(jīng)典題目;得多練練這個(gè)。

Runtime:?13 ms, faster than?77.51%?of?Java?online submissions for?01 Matrix.

Memory Usage:?44.3 MB, less than?92.71%?of?Java?online submissions for?01 Matrix.


LeetCode 542. 01 Matrix的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
永福县| 昌邑市| 宜春市| 离岛区| 高尔夫| 古浪县| 乐清市| 娱乐| 炎陵县| 齐齐哈尔市| 湾仔区| 喀什市| 石泉县| 郎溪县| 通州区| 巴彦县| 海淀区| 沙河市| 兴宁市| 怀化市| 贵南县| 娄底市| 永州市| 巴里| 双江| 乐业县| 镇江市| 瑞丽市| 固镇县| 渭南市| 静宁县| 南涧| 东源县| 延津县| 云阳县| 九龙城区| 郓城县| 方城县| 阿拉尔市| 沐川县| 通榆县|