Search
⌘K

Leetcode 302. Smallest Rectangle Enclosing Black Pixels

Given a binary image and the coordinates of one black pixel, compute the area of the smallest axis-aligned rectangle that contains all black ('1') pixels. The challenge is to determine the top/bottom/left/right boundaries efficiently (e.g., via binary search on rows/columns or DFS/BFS of the connected black region) rather than scanning the entire matrix.

Asked at:

Meta


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Early October, 2025

Meta

Mid-level

Comments

Your account is free and you can post anonymously if you choose.