Class Solution
java.lang.Object
g0901_1000.s0959_regions_cut_by_slashes.Solution
959 - Regions Cut By Slashes.<p>Medium</p>
<p>An <code>n x n</code> grid is composed of <code>1 x 1</code> squares where each <code>1 x 1</code> square consists of a <code>'/'</code>, <code>'\'</code>, or blank space <code>' '</code>. These characters divide the square into contiguous regions.</p>
<p>Given the grid <code>grid</code> represented as a string array, return <em>the number of regions</em>.</p>
<p>Note that backslash characters are escaped, so a <code>'\'</code> is represented as <code>'\\'</code>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2018/12/15/1.png" alt="" /></p>
<p><strong>Input:</strong> grid = [" /“,”/ "]</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2018/12/15/2.png" alt="" /></p>
<p><strong>Input:</strong> grid = [" /“,” "]</p>
<p><strong>Output:</strong> 1</p>
<p><strong>Example 3:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2018/12/15/4.png" alt="" /></p>
<p><strong>Input:</strong> grid = [“/\\”,“\\/”]</p>
<p><strong>Output:</strong> 5</p>
<p><strong>Explanation:</strong> Recall that because \ characters are escaped, “\\/” refers to \/, and “/\\” refers to /\.</p>
<p><strong>Constraints:</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> is either <code>'/'</code>, <code>'\'</code>, or <code>' '</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
regionsBySlashes
-