Regions Cut By Slashes Problem
Regions Cut By Slashes Problem — ExecCode Medium DSA Practice
Solve the Regions Cut By Slashes problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
An n x n grid is given as an array of strings, where each character is " " (blank), "/", or "\\". These characters divide the square into contiguous regions. Return the number of regions formed after every cell is sliced according to its character; slashes only ever connect the four triangular sub-cells they touch, never merge across a shared vertex alone.
Examples
Input {"grid": [" /", "/ "]}; Output 2. Input {"grid": [" /", " "]}; Output 1. Input {"grid": ["/\\", "\\/"]}; Output 5
Constraints
1 ≤ n ≤ 30 grid[i].length == n grid[i][j] is ' ', '/', or '\\'.
Practice Regions Cut By Slashes free on ExecCode. Browse DSA problems, topic map, and placement guides.