题目:原题链接(中等)
标签:排序、贪心算法
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | 68ms (99.50%) | ||
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def maximumElementAfterDecrementingAndRearranging(self, arr: List[int]) -> int:
arr.sort()
now = 0
for num in arr:
if num >= now + 1:
now += 1
return