1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/由斜杠划分区域 [regions-cut-by-slashes].html

48 lines
1.6 KiB
HTML
Raw Normal View History

2022-03-27 20:46:41 +08:00
<p>在由 <code>1 x 1</code> 方格组成的 <code>n&nbsp;x n</code>&nbsp;网格&nbsp;<code>grid</code> 中,每个 <code>1 x 1</code>&nbsp;方块由 <code>'/'</code><code>'\'</code> 或空格构成。这些字符会将方块划分为一些共边的区域。</p>
<p>给定网格&nbsp;<code>grid</code>&nbsp;表示为一个字符串数组,返回 <em>区域的数量</em></p>
<p>请注意,反斜杠字符是转义的,因此&nbsp;<code>'\'</code><code>'\\'</code>&nbsp;表示。</p>
<p>&nbsp;</p>
<ol>
</ol>
<p><strong>示例 1</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2018/12/15/1.png" style="height: 200px; width: 200px;" /></p>
<pre>
<strong>输入:</strong>grid = [" /","/ "]
<strong>输出:</strong>2</pre>
<p><strong>示例 2</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2018/12/15/2.png" style="height: 198px; width: 200px;" /></p>
<pre>
<strong>输入:</strong>grid = [" /"," "]
<strong>输出:</strong>1
</pre>
<p><strong>示例 3</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2018/12/15/4.png" style="height: 200px; width: 200px;" /></p>
<pre>
<strong>输入:</strong>grid = ["/\\","\\/"]
<strong>输出:</strong>5
<strong>解释:</strong>回想一下,因为 \ 字符是转义的,所以 "/\\" 表示 /\,而 "\\/" 表示 \/。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>n == grid.length == grid[i].length</code></li>
<li><code>1 &lt;= n &lt;= 30</code></li>
<li><code>grid[i][j]</code>&nbsp;<code>'/'</code><code>'\'</code>、或&nbsp;<code>' '</code></li>
</ul>