[LeetCode] Smallest Rectangle Enclosing Black Pixels

  • 时间:
  • 浏览:0

I try to use short and meaningful names: l, r, u, d in minArea are for left, right, up, and down; b, e in search are for begin and end; mini and maxi are the ranges of the other variable; first means whether we search for the left/up or the right/down boundary; row means whether we search for the row or the column.

This post shares very detailed explanation of how to use binary search to find the boundaries of the smallest rectangle that encloses the black pixels.

The code is as follows.