Statement▼
An n×n grid is composed of n, 1×1 squares, where each 1×1 square consists of a “/”, “\”, or a blank space. These characters divide the square into adjacent regions.
Given the grid represented as a string array, return the number of regions.
Note:
- Backslash characters are escaped, so “\” is represented as “\\”.
- A 1×1 square in the grid will be referred to as a box.
Constraints:
- The grid consists of only “/”, “\”, or " " characters.
- 1 ≤
grid.length
≤ 30
The following demonstration shows how the grid can be visualized: