Find every rectangular farmland group in a binary grid and return the coordinates of its top-left and bottom-right corners.
You are given a 2D binary grid where 1 represents farmland and 0 represents empty land. Each connected group of farmland forms one solid axis-aligned rectangle, and different rectangles do not touch each other horizontally or vertically.
Your task is to identify every farmland group and return the coordinates of its top-left and bottom-right cells.
Return the result in any order.
land of size m x n.land[i][j] is either 0 or 1.1s forms a single rectangle.[topRow, leftCol, bottomRow, rightCol].1 <= m, n <= 300land[i][j] is 0 or 1Example 1
Input
land = [[1,0,0],[0,1,1],[0,1,1]]
Output
[[0,0,0,0],[1,1,2,2]]
Explanation
There are two farmland rectangles: one single cell at the top-left, and one 2x2 block in the bottom-right.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.