i holds baskets[i] apples. The warehouse has crates, and crate j fits up to crates[j] apples.
All the apples have to be moved into crates. Apples from one basket may be split across several crates.
Return the smallest number of crates that is enough. The crates together are guaranteed to be large enough.baskets=[6, 2, 7], crates=[5, 9, 3, 8] → 2
There are 15 apples. The two largest crates hold 9 + 8 = 17 ≥ 15, and no single crate fits 15, so the answer is 2.
baskets=[4, 4], crates=[3, 3, 3] → 3
8 apples, while two crates hold only 6, so all three are needed.
baskets=[1, 1, 1], crates=[10, 2] → 1
baskets=[6, 2, 7], crates=[5, 9, 3, 8]
2
Run checks the first 3 tests in your browser. Submit checks all 77 tests on the server, hidden ones included.