Skip to content

Instantly share code, notes, and snippets.

@sanket1729
Last active April 5, 2023 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanket1729/8e65400a94d83906a8cdba30792417d7 to your computer and use it in GitHub Desktop.
Save sanket1729/8e65400a94d83906a8cdba30792417d7 to your computer and use it in GitHub Desktop.
class Solution:
def minimizeArrayValue(self, nums: List[int]) -> int:
total_sum = 0
ans = 0
for i, v in enumerate(nums):
capacity = ans * (i + 1)
total_sum += v
# Can we accomodate last value within current answer
if total_sum > capacity:
# Restribute equally.
ans = math.ceil(total_sum/(i + 1))
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment