Problem · Greedy

Determine Minimum Partitions Required

Learn this problem
MediumCloudflarePHONE SCREEN

Problem 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. 1. int[] partitions: an array of integers representing the size of each partition
  2. 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 = 2

Explanation: 2 partitions of [15, 20] can accommodate [5, 10, 15, 5].

drafts saved locally
public int determineMinPartitionsRequired(int[] partitions, int[] partitionsUsed) {
  // write your code here
}
partitions[10, 15, 15, 20]
partitionsUsed[5, 10, 15, 5]
expected2
checking account