Function
getArea
(matrix [][]byte, x, y int)
Source from the content-addressed store, hash-verified
| 42 | } |
| 43 | |
| 44 | func getArea(matrix [][]byte, x, y int) int { |
| 45 | maxArea := 0 |
| 46 | minWidth := 0 |
| 47 | width := 0 |
| 48 | length := 0 |
| 49 | for i := x; i < len(matrix); i++ { |
| 50 | if matrix[i][y] == '0' { |
| 51 | break |
| 52 | } |
| 53 | for j := y; j < len(matrix[0]); j++ { |
| 54 | if minWidth != 0 && j-y >= minWidth || matrix[i][j] == '0' { |
| 55 | break |
| 56 | } |
| 57 | |
| 58 | width++ |
| 59 | } |
| 60 | |
| 61 | length++ |
| 62 | if minWidth == 0 || width < minWidth { |
| 63 | minWidth = width |
| 64 | } |
| 65 | if width*length > maxArea { |
| 66 | maxArea = width * length |
| 67 | } |
| 68 | width = 0 |
| 69 | } |
| 70 | return maxArea |
| 71 | } |
Tested by
no test coverage detected