FastPrepDetermine Minimum Partitions Required
Problems/Determine Minimum Partitions Required

Determine Minimum Partitions Required

Cloudflare logoCloudflare● MediumPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

You have n disk partitions. partitions[i] is the size of partition i, and partitionsUsed[i] is how much data it holds right now.

You want to pack all the data into as few partitions as possible. Data can be moved in chunks, so the data from one partition may be split across several others. A partition can hold at most its size.

Return the minimum number of partitions needed to hold all the data.

For example, if the sizes are [10, 15, 15, 20] and the used amounts are [5, 10, 15, 5], there are 35 units of data. The partitions of size 20 and 15 hold 35 together, so the answer is 2.

Function

determineMinPartitionsRequired(partitions: int[], partitionsUsed: int[]) → int

Examples

Example 1

partitions = [10, 15, 15, 20]partitionsUsed = [5, 10, 15, 5]return = 2

The data adds up to 5 + 10 + 15 + 5 = 35. One partition is not enough, because the largest one holds only 20. The two largest partitions, 20 and 15, hold 35 together. So the answer is 2.

Constraints

  • 1 ≤ partitions.length ≤ 10^5
  • partitionsUsed.length == partitions.length
  • 1 ≤ partitionsUsed[i] ≤ partitions[i] ≤ 10^9

Similar questions at other companies

  • Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Apartment Housemate PreferencesGoogle · PHONE SCREENGoogle interview questions
  • Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
  • Remove the Fewest Magic BeansThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
  • Aggressive CowsAmazon · PHONE SCREEN
  • Minimize Range After Three ChangesDRW · PHONE SCREENDRW interview questions
  • Minimum Bus Fleet Across StationsSnowflake · PHONE SCREENSnowflake interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Fair Electoral Vote ApportionmentBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Experiment Bucket Allocation and RebalancingPinterest · PHONE SCREENPinterest interview questions
See Cloudflare hiring insights
Saved
class Solution {
    public int determineMinPartitionsRequired(int[] partitions, int[] partitionsUsed) {
      // write your code here
    }

}
Checking account…