Apple Redistribution into Boxes Problem

Apple Redistribution into Boxes Problem — ExecCode Easy DSA Practice

Solve the Apple Redistribution into Boxes problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an array apple of size n and an array capacity of size m. Your task is to compute the required answer and return the minimum number of boxes you need to select to redistribute these n packs of apples into boxes. 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. Note that, apples from the same pack can be distributed into different boxes.

Examples

Input {"apple": [1, 3, 2], "capacity": [4, 3, 1, 5, 2]}; Output 2. Input {"apple": [5, 5, 5], "capacity": [2, 4, 2, 7]}; Output 4

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.

Practice Apple Redistribution into Boxes free on ExecCode. Browse DSA problems, topic map, and placement guides.