3074. Apple Redistribution into Boxes Easy

@problem@discussion
#Array#Greedy#Sorting



1/**
2 * [3074] Apple Redistribution into Boxes
3 *
4 * You are given an array apple of size n and an array capacity of size m.
5 * There are n packs where the i^th pack contains apple[i] apples. There are m boxes as well, and the i^th box has a capacity of capacity[i] apples.
6 * Return the minimum number of boxes you need to select to redistribute these n packs of apples into boxes.
7 * Note that, apples from the same pack can be distributed into different boxes.
8 *  
9 * <strong class="example">Example 1:
10 * 
11 * Input: apple = [1,3,2], capacity = [4,3,1,5,2]
12 * Output: 2
13 * Explanation: We will use boxes with capacities 4 and 5.
14 * It is possible to distribute the apples as the total capacity is greater than or equal to the total number of apples.
15 * 
16 * <strong class="example">Example 2:
17 * 
18 * Input: apple = [5,5,5], capacity = [2,4,2,7]
19 * Output: 4
20 * Explanation: We will need to use all the boxes.
21 * 
22 *  
23 * Constraints:
24 * 
25 * 	1 <= n == apple.length <= 50
26 * 	1 <= m == capacity.length <= 50
27 * 	1 <= apple[i], capacity[i] <= 50
28 * 	The input is generated such that it's possible to redistribute packs of apples into boxes.
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/apple-redistribution-into-boxes/
34// discuss: https://leetcode.com/problems/apple-redistribution-into-boxes/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn minimum_boxes(apple: Vec<i32>, capacity: Vec<i32>) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_3074() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.