Minimize array maximum
You are given an array nums and an integer threshold. Repeatedly you may pick any index i (1 <= i < len(nums)) where nums[i] > 0, decrement nums[i] by 1 and increment nums[i-1] by 1. After any number of such operations, return the minimum possible value of the maximum element of the array. Constraints: 1 <= len(nums) <= 10^5, 0 <= nums[i] <= 10^9.
Implement
minimize_array_max(nums: list[int]) → intExamples
in
[[3,7,1,6]]out5What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 35 min
solution.py
InputExpectedGot
[[3,7,1,6]]5not run yetsample