FastPrepFastPrep
Problem Brief

Minimum Days to Deliver Parcels

FULLTIMEOA
See Amazon online assessment and hiring insights

Amazon Delivery Centers dispatch parcels every day. There are n delivery centers, each having parcels[i] parcels to be delivered. On each day, an equal number of parcels are to be dispatched from each delivery center that has at least one parcel remaining. Find the minimum number of days needed to deliver all the parcels.

Function Description

Complete the function minDaysToDeliverParcels in the editor below.

minDaysToDeliverParcels has the following parameters: int parcels[n]: the number of parcels at each center

Returns

int: the minimum number of days needed to deliver all the parcels

Constraints

  • 1 ≤ n ≤ 10^6
  • 0 ≤ parcels[i] ≤ 10^9

1Example 1

Input
parcels = [2, 3, 4, 3, 3]
Output
3
Explanation
All parcels can be delivered in a minimum of 3 days.

2Example 2

Input
parcels = [3, 3, 3, 3, 3, 3]
Output
1
Explanation
Each delivery center can dispatch its 3 parcels on the first day.

Constraints

Limits and guarantees your solution can rely on.

  • 1 ≤ n ≤ 10^6
  • 0 ≤ parcels[i] ≤ 10^9
  • public int minDaysToDeliverParcels(int[] parcels) {
      // write your code here
    }
    
    Input

    parcels

    [2, 3, 4, 3, 3]

    Output

    3

    Sign in to submit your solution.