Problem · Greedy
Determine Minimum Partitions Required
You were given a list of partitions and partitions used, determine the minimum amount of partitions required to fit all partitions. Data can be moved in chunks.
Complete the function determineMinPartitionsRequired in the editor.
determineMinPartitionsRequired has the following parameters:
- 1.
int[] partitions: an array of integers representing the size of each partition - 2.
int[] partitionsUsed: an array of integers representing the used space in each partition
Returns
int: the minimum number of partitions required
Examples
01 · Example 1
partitions = [10, 15, 15, 20] partitionsUsed = [5, 10, 15, 5] return = 2
Explanation: 2 partitions of [15, 20] can accommodate [5, 10, 15, 5].
public int determineMinPartitionsRequired(int[] partitions, int[] partitionsUsed) {
// write your code here
}
partitions[10, 15, 15, 20]
partitionsUsed[5, 10, 15, 5]
expected2
sign in to submit