Skip to content

Commit f607b2a

Browse files
solves minimise maximum of the array (#2439) in python
1 parent 98d18de commit f607b2a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/minimize_maximum_of_array.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# https://leetcode.com/problems/minimize-maximum-of-array/description/
2+
# T:O(n) where n is the number of elements in the array
3+
# S:O(1)
4+
5+
class Solution:
6+
def minimizeArrayValue(self, nums: List[int]) -> int:
7+
minimumValue = 0
8+
prefixSum = 0
9+
for i, num in enumerate(nums):
10+
prefixSum += num
11+
minimumValue = max(minimumValue,((prefixSum+i)//(i+1)))
12+
return minimumValue

0 commit comments

Comments
 (0)