mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
48 lines
1.6 KiB
HTML
48 lines
1.6 KiB
HTML
|
<p>在由 <code>1 x 1</code> 方格组成的 <code>n x n</code> 网格 <code>grid</code> 中,每个 <code>1 x 1</code> 方块由 <code>'/'</code>、<code>'\'</code> 或空格构成。这些字符会将方块划分为一些共边的区域。</p>
|
|||
|
|
|||
|
<p>给定网格 <code>grid</code> 表示为一个字符串数组,返回 <em>区域的数量</em> 。</p>
|
|||
|
|
|||
|
<p>请注意,反斜杠字符是转义的,因此 <code>'\'</code> 用 <code>'\\'</code> 表示。</p>
|
|||
|
|
|||
|
<p> </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> </p>
|
|||
|
|
|||
|
<p><strong>提示:</strong></p>
|
|||
|
|
|||
|
<ul>
|
|||
|
<li><code>n == grid.length == grid[i].length</code></li>
|
|||
|
<li><code>1 <= n <= 30</code></li>
|
|||
|
<li><code>grid[i][j]</code> 是 <code>'/'</code>、<code>'\'</code>、或 <code>' '</code></li>
|
|||
|
</ul>
|