gary@interview:~/interview/coding/1992-find-all-gr….md$
$ cat ./coding/1992-find-all-groups-of-farmland.md
[Coding]

1992. Find All Groups of Farmland

────────────────────────────────────────────────────────────

1992. Find All Groups of Farmland

class Solution:
    def findFarmland(self, land: List[List[int]]) -> List[List[int]]:
        res = []

        m = len(land)
        n = len(land[0])

        def helper(i, j):
            k = i
            w = j
            while k < m and land[k][j] == 1:
                k += 1
            while w < n and land[i][w] == 1:
                w += 1
            for x in range(i, k):
                for y in range(j, w):
                    land[x][y] = 0
            
            return [i, j, k - 1, w - 1]

        res = []
        for i in range(m):
            for j in range(n):
                if land[i][j] == 1:
                    res.append(helper(i, j))
        
        return res


--tags#Tree
$ ls ./coding/ | grep -v 1992-find-all-groups-of-farmland
265. Paint House II256. Paint House143. Reorder List1762. Buildings With an Ocean View
← cd ../codingcd ~