Skip to content

Commit 8d2feab

Browse files
authored
Create maximum-element-after-decreasing-and-rearranging.py
1 parent b7c895b commit 8d2feab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Time: O(nlogn)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def maximumElementAfterDecrementingAndRearranging(self, arr):
6+
"""
7+
:type arr: List[int]
8+
:rtype: int
9+
"""
10+
arr.sort()
11+
result = 1
12+
for i in xrange(1, len(arr)):
13+
result = min(result+1, arr[i])
14+
return result

0 commit comments

Comments
 (0)