Problem · Array
Get Max Increments
Learn this problemProblem statement
IMDB, an Amazon-owned company, is a widely used platform for discovering scores of films and television series.
Researchers are examining audience preferences by studying sequences of film scores. One specific metric they focus on is counting how many positions exist where a score is directly followed by a higher score. Their goal is to determine the largest possible count of such positions by rearranging the scores in the most efficient manner.
Given an array scores consisting of n integers, compute the highest possible number of indices i such that scores[i] < scores[i + 1] after optimally reordering the array.
Function
getMaxIncrements(scores: int[]) → intExamples
Example 1
scores = [2, 1, 3]return = 2
Example 2
scores = [2, 1, 1, 2]return = 2In this scenairo, an optimal arrangement of the arr scores is [1, 2, 1, 2].
The indices i such that scores[i] < scores[i + 1], are [0, 1].
So answer is 2.
P.S. This test cases was added on 04-13-2025 :) Relevant ss was attached in the Problem Source section.
Example 3
scores = [2, 3, 1, 5, 4]return = 4In this case, an very optimal arrangement of the arr scores is [1, 2, 3, 4, 5].
the indices i such that scores[i] < scores[i + 1], are [0, 1, 2, 3].
So answer is 4.
P.S. This test cases was added on 04-13-2025 :) Relevant ss was attached in the Problem Source section.
Constraints
2 ≤ n ≤ 2 * 10^51 ≤ scores[i] ≤ 2 * 10^5
More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026