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

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

LeetCode 130. Surrounded Regions

2022-11-18 20:50 作者:您是打尖兒還是住店呢  | 我要投稿

Given an?m x n?matrix?board?containing?'X'?and?'O',?capture all regions that are 4-directionally?surrounded by?'X'.

A region is?captured?by flipping all?'O's into?'X's in that surrounded region.

?

Example 1:

Input: board = [["X","X","X","X"],["X","O","O","X"],["X","X","O","X"],["X","O","X","X"]]Output: [["X","X","X","X"],["X","X","X","X"],["X","X","X","X"],["X","O","X","X"]]Explanation: Notice that an 'O' should not be flipped if: - It is on the border, or - It is adjacent to an 'O' that should not be flipped. The bottom 'O' is on the border, so it is not flipped. The other three 'O' form a surrounded region, so they are flipped.

Example 2:

Input: board = [["X"]]Output: [["X"]]

?

Constraints:

  • m == board.length

  • n == board[i].length

  • 1 <= m, n <= 200

  • board[i][j]?is?'X'?or?'O'.


典型的DFS先將邊上的為O的改成#,然后dfs跟他相關(guān)聯(lián)的位置也一并改成#,剩下的O就是唄X包圍著的,然后2個(gè)for循環(huán)就可以了。



Runtime:?4 ms, faster than?63.84%?of?Java?online submissions for?Surrounded Regions.

Memory Usage:?52.7 MB, less than?13.82%?of?Java?online submissions for?Surrounded Regions.

Next challenges:

Walls and Gates


LeetCode 130. Surrounded Regions的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
团风县| 博乐市| 汝南县| 安顺市| 新龙县| 尼勒克县| 普陀区| 邵东县| 镇巴县| 连山| 泊头市| 射阳县| 清流县| 洛宁县| 凤凰县| 安乡县| 娄烦县| 阿鲁科尔沁旗| 林芝县| 基隆市| 中卫市| 嘉黎县| 安西县| 陕西省| 巴塘县| 娄底市| 西昌市| 株洲市| 安吉县| 太原市| 曲麻莱县| 潞西市| 社旗县| 公主岭市| 平山县| 靖边县| 翁源县| 七台河市| 娱乐| 新田县| 高平市|