Close
Topic list
Regions Cut By Slashes
MEDIUM
30 mins
Graph
Topics (Covered in this problem)
Problem solved
Skill meter
Graph
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Regions Cut By Slashes

Contributed by
Deep Mavani
Medium
0/80
Avg time to solve 30 mins
Success Rate 70 %
Share

## Problem Statement

#### This time our favorite Ninja wants to buy a house. But they are unable to count the number of rooms in the house. So they need your help to count the number of rooms.

##### Note:
``````A house is represented by a matrix where “\” and “/” represent a wall and blank space is empty space. We will consider two rooms different if we will be unable to reach another room.
``````

#### Your task is to return the number of rooms. For a better explanation, see the example.

##### Example:
``````Input:
[
“ /”
“/\”
]

Output: 3

Explanation: 2 X 2 house is shown below:
``````

Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````2
2
\/
/\
3
/ /
/
/
``````
##### Sample Output 1:
``````4
3
``````
##### Explanation of Sample Output 1:
``````In test case 1, We can see there are 4 separate rooms.
``````

``````In test case 2, we can see there are 3 separate rooms.
``````

##### Sample Input 2:
``````1
2
/
/\
``````

#### Sample Output 2:

``````3
``````
##### Explanation of Sample Output 2:
``````In test case 1, We can see there are 4 separate rooms.
``````

Auto
Console