Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 427 Bytes

1846.md

File metadata and controls

17 lines (15 loc) · 427 Bytes

1846. Maximum Element After Decreasing and Rearranging

Solution 1 (time O(nlog(n)), space O(1))

class Solution(object):
    def maximumElementAfterDecrementingAndRearranging(self, arr):
        """
        :type arr: List[int]
        :rtype: int
        """
        arr.sort()
        arr[0] = 1
        for i in range(1, len(arr)):
            arr[i] = min(arr[i], arr[i - 1] + 1)
        return arr[-1]