Smallest Rectangle Enclosing Black Pixels
Explore how to identify the smallest rectangle enclosing all connected black pixels in a binary matrix. This lesson helps you understand matrix traversal and design an algorithm with runtime complexity less than O(m×n), improving problem-solving skills for coding interviews.
We'll cover the following...
We'll cover the following...
Statement
You are given an image, where
All black pixels in the matrix form a single connected region, where connectivity is defined by horizontal or vertical adjacency.
Given two integers x and y that represent the coordinates of one of the black pixels, write an algorithm to find the area of the smallest axis-aligned rectangle that encloses all the black ...