add new solutions
This commit is contained in:
parent
0c73608ce5
commit
d798d5e8c9
19 changed files with 661 additions and 4 deletions
27
solutions/29/q2943/solution.go
Normal file
27
solutions/29/q2943/solution.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package q2943
|
||||
|
||||
import "slices"
|
||||
|
||||
func longestSeq(arr []int) int {
|
||||
max_ := 1
|
||||
len_ := 1
|
||||
for i := 1; i < len(arr); i++ {
|
||||
if arr[i] == arr[i-1]+1 {
|
||||
len_++
|
||||
} else {
|
||||
len_ = 1
|
||||
}
|
||||
max_ = max(len_, max_)
|
||||
}
|
||||
return max_
|
||||
}
|
||||
|
||||
func maximizeSquareHoleArea(n, m int, hBars, vBars []int) int {
|
||||
slices.Sort(hBars)
|
||||
slices.Sort(vBars)
|
||||
|
||||
edge := min(longestSeq(hBars), longestSeq(vBars)) + 1
|
||||
return edge * edge
|
||||
}
|
||||
|
||||
var _ = maximizeSquareHoleArea
|
||||
Loading…
Add table
Add a link
Reference in a new issue