Maximum Element After Decreasing and Rearranging

Solution Code

Time Complexity

O(n log n)

Space Complexity

O(log n) or O(n)