Problem · Greedy
Determine Minimum Partitions Required
Learn this problemProblem statement
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.
Function
determineMinPartitionsRequired(partitions: int[], partitionsUsed: int[]) → int
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
Example 1
partitions = [10, 15, 15, 20]partitionsUsed = [5, 10, 15, 5]return = 2Explanation: 2 partitions of [15, 20] can accommodate [5, 10, 15, 5].