loads[i] is the number of jobs on server i. In one step you may take one job from server i (where i ≥ 1 and loads[i] > 0) and hand it to its left neighbour, server i − 1.
You may take any number of steps. Return the smallest possible value of the largest load in the row.loads=[2, 8, 0, 6] → 5
Move 3 units from position 1 to position 0: [5, 5, 0, 6]. Then 1 unit from position 3 to position 2: [5, 5, 1, 5]. The maximum is 5, and it cannot go lower because the first two positions hold 10 together.
loads=[9, 2, 4] → 9
Load only moves left, and position 0 already holds 9, which can never decrease.
loads=[0, 0, 7] → 3
len(loads) ≤ 10⁵loads[i] ≤ 10⁹loads=[2, 8, 0, 6]
5
Run checks the first 3 tests in your browser. Submit checks all 115 tests on the server, hidden ones included.