FastPrepFastPrep
Problem Brief

Donut Challenge

INTERNOA

A bakery is having a donut eating challenge! In order to win, you must eat all numBoxes boxes of donuts, with the i-th box having donutBoxes[i] number of donuts. To make things more difficult, the challenge has a time limit of numMinutes minutes.

Your plan is to eat d donuts per minute, but in each minute you will only eat donuts from a single box. If a box contains fewer than d donuts, you will only eat the number of donuts in that box and you will wait until the next minute to eat more donuts.

You know you can win the challenge, but you want to pace yourself. What is the smallest number of donuts d you need to eat per minute in order to eat all the donuts within the time limit?

Input Format

The first line of the input will be an integer, numBoxes, representing the total number of boxes. The following numBoxes lines of the input will be integers, representing the number of donuts in each box. The i-th line will be donutBoxes[i], the number of donuts in the i-th box. The last line of the input will be an integer, numMinutes, representing the time limit of the challenge.

Output Format

The output will be an integer, representing the smallest number of donuts (d) that you need to eat per minute in order to complete the challenge within the time limit.

1Example 1

Input
donutBoxes = [4, 9, 11, 17], numMinutes = 8
Output
6
Explanation
:)

Constraints

Limits and guarantees your solution can rely on.

  • The time limit of the challenge in minutes (numMinutes) will always be equal to, or greater than, the number of donut boxes (numBoxes).
  • There will be at least one donut to eat in each box.
public int minDonutsPerMinute(int[] donutBoxes, int numMinutes) {
  // write your code here
}
Input

donutBoxes

[4, 9, 11, 17]

numMinutes

8

Output

6

Sign in to submit your solution.