Class Solution
-
- All Implemented Interfaces:
public final class Solution959 - Regions Cut By Slashes\.
Medium
An
n x ngrid is composed of1 x 1squares where each1 x 1square consists of a'/','\', or blank space' '. These characters divide the square into contiguous regions.Given the grid
gridrepresented as a string array, return the number of regions.Note that backslash characters are escaped, so a
'\'is represented as'\\'.Example 1:
Input: grid = " /","/ "
Output: 2
Example 2:
Input: grid = " /"," "
Output: 1
Example 3:
Input: grid = "/\\\\","\\\\/"
Output: 5
Explanation: Recall that because \\ characters are escaped, "\\\\/" refers to \\/, and "/\\\\" refers to /\\.
Constraints:
n == grid.length == grid[i].length1 <= n <= 30grid[i][j]is either'/','\', or' '.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegerregionsBySlashes(Array<String> grid)-
-
Method Detail
-
regionsBySlashes
final Integer regionsBySlashes(Array<String> grid)
-
-
-
-