五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

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

leetcode463. Island Perimeter

2022-02-26 10:22 作者:您是打尖兒還是住店呢  | 我要投稿

You are given?row x col?grid?representing a map where?grid[i][j] = 1?represents?land and?grid[i][j] = 0?represents water.

Grid cells are connected?horizontally/vertically?(not diagonally). The?grid?is completely surrounded by water, and there is exactly one island (i.e., one or more connected land cells).

The island doesn't have "lakes", meaning the water inside isn't connected to the water around the island. One cell is a square with side length 1. The grid is rectangular, width and height don't exceed 100. Determine the perimeter of the island.

?

Example 1:

Input: grid = [[0,1,0,0],[1,1,1,0],[0,1,0,0],[1,1,0,0]]Output: 16Explanation: The perimeter is the 16 yellow stripes in the image above.

Example 2:

Input: grid = [[1]]Output: 4

Example 3:

Input: grid = [[1,0]]Output: 4

如果這個位置上是1,那么加4,當出現(xiàn)相鄰的時候,則需要減去2,所以遍歷左邊跟上邊的所有情況,因為右邊跟下邊會在后面i++,j++的時候遍歷到;

Runtime:?4 ms, faster than?100.00%?of?Java?online submissions for?Island Perimeter.

Memory Usage:?42.9 MB, less than?80.05%?of?Java?online submissions for?Island Perimeter.


leetcode463. Island Perimeter的評論 (共 條)

分享到微博請遵守國家法律
射阳县| 康保县| 富顺县| 无为县| 灌南县| 新绛县| 东海县| 伊吾县| 鄯善县| 阜新| 宾川县| 鄱阳县| 秦皇岛市| 龙泉市| 望城县| 牡丹江市| 余干县| 大港区| 济南市| 毕节市| 平武县| 余姚市| 谷城县| 古浪县| 雅江县| 承德县| 颍上县| 康马县| 阿勒泰市| 来宾市| 赤峰市| 石渠县| 黔江区| 樟树市| 涡阳县| 广宗县| 延寿县| 石楼县| 定结县| 通榆县| 互助|