{ "id": 3334, "name": "apple_redistribution_into_boxes", "difficulty": "Easy", "link": "https://leetcode.com/problems/apple-redistribution-into-boxes/", "date": "2024-03-03 00:00:00", "task_description": "You are given an array `apple` of size `n` and an array `capacity` of size `m`. There are `n` packs where the `ith` pack contains `apple[i]` apples. There are `m` boxes as well, and the `ith` box has a capacity of `capacity[i]` apples. Return _the **minimum** number of boxes you need to select to redistribute these _`n`_ packs of apples into boxes_. **Note** that, apples from the same pack can be distributed into different boxes. **Example 1:** ``` **Input:** apple = [1,3,2], capacity = [4,3,1,5,2] **Output:** 2 **Explanation:** We will use boxes with capacities 4 and 5. It is possible to distribute the apples as the total capacity is greater than or equal to the total number of apples. ``` **Example 2:** ``` **Input:** apple = [5,5,5], capacity = [2,4,2,7] **Output:** 4 **Explanation:** We will need to use all the boxes. ``` **Constraints:** `1 <= n == apple.length <= 50` `1 <= m == capacity.length <= 50` `1 <= apple[i], capacity[i] <= 50` The input is generated such that it's possible to redistribute packs of apples into boxes.", "public_test_cases": [ { "label": "Example 1", "input": "apple = [1,3,2], capacity = [4,3,1,5,2]", "output": "2 " }, { "label": "Example 2", "input": "apple = [5,5,5], capacity = [2,4,2,7]", "output": "4 " } ], "private_test_cases": [ { "input": [ [ 12, 39, 47, 10, 21, 26, 7, 50 ], [ 49, 43, 35, 30, 29, 28, 24, 7 ] ], "output": 6 }, { "input": [ [ 35, 48, 40, 16, 43, 36, 41, 4 ], [ 46, 45, 45, 44, 43, 40, 38, 38, 36, 34, 34, 33, 30, 29, 28, 26, 25, 24, 22, 22, 19, 18, 17, 7, 2, 2, 2, 1 ] ], "output": 6 }, { "input": [ [ 18, 45, 11, 47, 26, 2, 39, 48, 43, 16, 4, 17, 48, 44, 2, 21, 41, 40, 17, 29, 35, 23, 45, 30, 31, 34, 39 ], [ 205, 50, 45, 45, 45, 42, 39, 37, 35, 35, 31, 27, 26, 24, 24, 21, 21, 15, 14, 8, 6 ] ], "output": 21 }, { "input": [ [ 46, 5, 6, 15, 47, 20, 16, 19, 42, 44, 44, 28, 28, 19, 16, 26, 47, 12, 39, 40, 25, 25, 48, 3, 17, 6, 21, 22, 20, 2, 50, 50, 26, 26, 41, 5, 9, 31, 19, 40, 26 ], [ 719, 50, 49, 41, 31, 28, 28, 23, 22, 20, 15, 11, 11, 10, 8, 5 ] ], "output": 16 }, { "input": [ [ 14, 12, 1, 27, 27, 29, 14, 12, 7, 6, 8, 42, 34, 42, 44, 46, 27, 49, 36, 24 ], [ 163, 46, 44, 44, 40, 37, 35, 34, 25, 12, 9, 8, 4 ] ], "output": 13 }, { "input": [ [ 28, 3, 15, 44, 49, 25, 11, 50, 32, 2 ], [ 43, 39, 37, 36, 35, 35, 33, 32, 28, 25, 20, 16, 16, 6, 3, 2 ] ], "output": 8 }, { "input": [ [ 38, 42, 47, 16, 36 ], [ 50, 49, 48, 47, 47, 47, 44, 44, 42, 38, 36, 35, 35, 34, 34, 33, 31, 29, 29, 26, 26, 23, 19, 19, 18, 15, 14, 14, 13, 12, 12, 11, 8, 7, 7, 5, 4, 1, 1 ] ], "output": 4 }, { "input": [ [ 44, 26, 43, 38, 50, 35, 36, 44, 25, 39, 16, 14, 26, 12, 3, 45, 21, 1, 4, 8, 35, 2, 33, 30, 9, 26, 20, 16, 14, 24, 43, 7 ], [ 271, 46, 42, 40, 40, 40, 39, 38, 36, 34, 28, 28, 27, 23, 19, 13, 11, 8, 6 ] ], "output": 19 }, { "input": [ [ 49, 46, 14, 38, 24, 32, 16, 36, 22, 19, 48, 17, 43, 15, 9, 3, 18, 42, 4, 49, 12, 20, 16, 22, 11, 28, 36, 1, 7, 18, 49, 17, 3, 4, 36, 7, 37, 18, 7, 41, 18, 13, 5 ], [ 919, 30, 16, 5 ] ], "output": 4 }, { "input": [ [ 41, 30, 18, 6 ], [ 41, 34, 20 ] ], "output": 3 } ], "haskell_template": "minimumBoxes :: [Int] -> [Int] -> Int\nminimumBoxes apple capacity ", "ocaml_template": "let minimumBoxes (apple: int list) (capacity: int list) : int = ", "scala_template": "def minimumBoxes(apple: List[Int],capacity: List[Int]): Int = { \n \n}", "java_template": "class Solution {\n public int minimumBoxes(int[] apple, int[] capacity) {\n \n }\n}", "python_template": "class Solution(object):\n def minimumBoxes(self, apple, capacity):\n \"\"\"\n :type apple: List[int]\n :type capacity: List[int]\n :rtype: int\n \"\"\"\n " }