Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 703b901

Browse files
Create 1846.py
1 parent a3b87cc commit 703b901

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎1846.py‎

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /