Description
Solutions
Minimize Maximum Parcels
πŸ‘©β€πŸŽ“ NEW GRAD🀘 INTERN

You are give:

  • An integer array packages[i], where each element represents the number of packages currently assigned to the i-th delivery center.
  • An integer extra_packages, which denotes the total number of additional packages that must be distributed among the delivery centers.
  • Our mission this time is to help the company calculate the minimum possible value of the maximum number of packages assigned to any delivery center after distributing all the extra packages optimally.

    Example 1:

    Input:  packages = [7, 5, 1, 9, 1], extra_packages = 25
    Output: 10
    Explanation:
    There are other possible optimal assignments, but the minimum value of the maximum value of the maximum number of pacakges any delivery center will deliver is 10. (Updated on 2025-01-19)

    Example 2:

    Input:  packages = [1, 2, 3], extra_packages = 3
    Output: 3
    Explanation:
    Assign two extra pacakges to the 1st delivery center and one extra to the second center. Eventually, each center will have to send three packages. (Added on 2025-02-15)

    Example 3:

    Input:  packages = [1], extra_packages = 3
    Output: 4
    Explanation:
    Because we have only 1 delivery center, all the extra packages will be assigned to the same :) (Added on 2025-02-15)
    Constraints:
    • 1 <= n <= 10^5
    • 1 <= extra_packages <= 10^15
    • 1 <= packages[i] <= 10^9
    • constraints added on 01-27-2025
    Thumbnail 0
    Thumbnail 1
    Thumbnail 2
    Thumbnail 3
    Thumbnail 4
    Testcase

    Result
    Case 1

    input:

    output: