mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-12 09:58:38 +08:00
routine
This commit is contained in:
20
25/12/go/3074.go
Normal file
20
25/12/go/3074.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package A
|
||||
|
||||
import "slices"
|
||||
|
||||
func minimumBoxes(apple []int, capacity []int) int {
|
||||
sum := 0
|
||||
for _, i := range apple {
|
||||
sum += i
|
||||
}
|
||||
slices.SortFunc(capacity, func(a, b int) int { return b - a })
|
||||
ans := 0
|
||||
for _, i := range capacity {
|
||||
sum -= i
|
||||
ans++
|
||||
if sum <= 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
Reference in New Issue
Block a user