add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
31
solutions/0/q85/solution.go
Normal file
31
solutions/0/q85/solution.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package q85
|
||||
|
||||
func maximalRectangle(matrix [][]byte) int {
|
||||
var maxArea int
|
||||
|
||||
for row := range matrix {
|
||||
for col := range matrix[0] {
|
||||
matrix[row][col] -= '0'
|
||||
if matrix[row][col] == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if col > 0 {
|
||||
matrix[row][col] += matrix[row][col-1]
|
||||
}
|
||||
|
||||
maxW := matrix[row][col]
|
||||
for i := 0; row-i >= 0; i++ {
|
||||
if matrix[row-i][col] == 0 {
|
||||
break
|
||||
}
|
||||
maxW = min(maxW, matrix[row-i][col])
|
||||
maxArea = max(maxArea, int(maxW)*(i+1))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maxArea
|
||||
}
|
||||
|
||||
var _ = maximalRectangle
|
||||
Loading…
Add table
Add a link
Reference in a new issue