refactor: refactor project structure
This commit is contained in:
40
legacy/3195 minimumArea/Go/main.go
Executable file
40
legacy/3195 minimumArea/Go/main.go
Executable file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func minimumArea(grid [][]int) int {
|
||||
row := len(grid)
|
||||
col := len(grid[0])
|
||||
|
||||
min_x := col
|
||||
max_x := 0
|
||||
min_y := row
|
||||
max_y := 0
|
||||
|
||||
for i:=0; i<row; i++{
|
||||
for j:=0; j<col; j++{
|
||||
if grid[i][j] == 1{
|
||||
min_x = Min(min_x, j)
|
||||
max_x = Max(max_x, j)
|
||||
min_y = Min(min_y, i)
|
||||
max_y = Max(max_y, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (max_x-min_x+1) * (max_y-min_y+1)
|
||||
}
|
||||
|
||||
func Min(a, b int)int{
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func Max(a, b int)int{
|
||||
if a > b{
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
Reference in New Issue
Block a user