Find a rectangle of 0s in matrix of 1s and 0s

Question: Find a rectangle of 0s in matrix of 1s and 0s
Input:

Output: [[0, 0], [0, 0], [3, 3], [7, 4]]

Solution: 
Key to solve this question is to mark visited element as 1.
Usually, interviewer starts with a question where they ask you to assume just one rectangle. And once you implement it, they will ask you to modify it such that there might be multiple rectangles and return the array of all the co ordinates. So, make sure that whatever method you add at the start is easily extensible.

Code:

Complexity: O(row * column)

Git Url: FindRectangles.java

Leave a Reply

Your email address will not be published. Required fields are marked *