add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
21
solutions/30/q3074/solution.go
Normal file
21
solutions/30/q3074/solution.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package q3074
|
||||
|
||||
import "slices"
|
||||
|
||||
func minimumBoxes(apple []int, capacity []int) int {
|
||||
apples := 0
|
||||
for _, a := range apple {
|
||||
apples += a
|
||||
}
|
||||
|
||||
slices.Sort(capacity)
|
||||
for i := len(capacity) - 1; i >= 0; i-- {
|
||||
apples -= capacity[i]
|
||||
if apples <= 0 {
|
||||
return len(capacity) - i
|
||||
}
|
||||
}
|
||||
return len(capacity)
|
||||
}
|
||||
|
||||
var _ = minimumBoxes
|
||||
Loading…
Add table
Add a link
Reference in a new issue