0959. Regions Cut By Slashes

https://leetcode.com/problems/regions-cut-by-slashes

Description

An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '. These characters divide the square into contiguous regions.

Given the grid grid represented as a string array, return the number of regions.

Note that backslash characters are escaped, so a '\' is represented as '\\'.

Example 1:

Example 2:

Example 3:

Example 4:

Example 5:

Constraints:

  • n == grid.length

  • n == grid[i].length

  • 1 <= n <= 30

  • grid[i][j] is either '/', '\', or ' '.

ac

Last updated

Was this helpful?