0
点赞
收藏
分享

微信扫一扫

LeetCode题解(1846):减小和重新排列数组后的最大元素(Python)


题目:​​原题链接​​(中等)

标签:排序、贪心算法

解法

时间复杂度

空间复杂度

执行用时

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


举报

相关推荐

0 条评论