Practice Maximum Element After Decreasing and Rearranging
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You may reorder arr and decrease any entry to a smaller positive integer, any number of times. The resulting array must start with 1 and adjacent entries must differ by at most 1. Return the greatest attainable value of any entry while meeting both conditions.
Source: Maximum Element After Decreasing and Rearranging on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = [2,2,1,2,1]
Output
2
# Example 2
Input
arr = [100,1,1000]
Output
3
# Example 3
Input
arr = [1,2,3,4,5]
Output
5
Constraints
1 <= arr.length <= 10^5
1 <= arr[i] <= 10^9
Related LeetCode Problems
Practice more problems similar to Maximum Element After Decreasing and Rearranging.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.