Company: IBM___.
Difficulty: medium
Maximum Element After Decreasing and Rearranging Problem Description You are given an array of integers, and you must transform it so that both of these hold: The very first element of the array equals 1. Every later element differs from the one before it by at most 1 upward. Formally, for every index i with 1 ≤ i < n, arr[i] - arr[i-1] ≤ 1 . Allowed operations: Rearrange the array elements into whatever order you like. Lower any single element to any value that is still at least 1. Report the largest value that the last element of the array can end up holding. Example Input: arr = [3, 1, 3, 4] Output: 4 Explanation: One way to reach the largest possible final value: Sort the array into non-decreasing order first: [1, 3, 3, 4] . Make sure the first element equals 1 — here it already does, so the array stays [1, 3, 3, 4] . Walk through the remaining elements and enforce the adjacent-difference rule. The second element ( arr[1]=3 ) cannot exceed arr[0] + 1 = 2 , so lower it to 2