As part of your Day 1 orientation at Amazon, your new team is hosting a programming challenge. You've been asked to participate in completing the following task. Given an array of integers, perform certain operations in order to satisfy some constraints. The constraints are as follows:
- The first array element must be 1.
- For all other elements, the difference between adjacent integers must not be greater than 1. In other words, for 1 ≤ i < n, arr[i] - arr[i-1] ≤ 1.
To accomplish this, the following operations are available:
- Rearrange the elements in any way.
- Reduce any element to any number that is at least 1.
What is the maximum value that can be achieved for the final element of the array by following these operations and constraints?
Duplicate note (July 2, 2026) 𐔌՞ ܸ.ˬ.ܸ՞𐦯 : This problem is the same question as Maximum Final Value. I merged this page's sighting dates into that version, so this page will not be updated anymore. If you want to practice, I recommend practicing Maximum Final Value.
arr = [3, 1, 3, 4] return = 4
1. Subtract 1 from the first element, making the array [2, 1, 3, 4].
2. Rearrange the array into [1, 2, 3, 4].
3. The final element's value is 4, the maximum value that can be achieved. Therefore, the answer is 4.
- Closest Version DateONSITE INTERVIEW · Seen Jul 2026
- Maximum Concurrent Processes (Bar Raiser Round)ONSITE INTERVIEW · Seen Jul 2026
- Maximum Product New RatingOA · Seen Jul 2026
- Permutation SorterOA · Seen Jul 2026
- Get Distinct Pairs (Also apply to AS intern)Seen Jul 2026
- Maximum Final ValueSeen Jul 2026
- Minimum Delivery Center InconvenienceOA · Seen Jun 2026
- Unfulfilled Customers by Inventory PriorityOA · Seen Jun 2026
public int maximizeFinalElement(int[] arr) {
// write your code here
}