Get Max Increments
Updated
Problem 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 interview questions
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Maximal SquareONSITE INTERVIEW · Seen Nov 2026
- Serialize and Deserialize a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Diagonal Traversal of a Binary TreeONSITE INTERVIEW · Seen Nov 2026
- Minimum Time to Spread Through a GridPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Consistent-Hash Packet RouterPHONE SCREEN · Seen Nov 2026
- Count Connected ComponentsPHONE SCREEN · Seen Nov 2026
- Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026
Similar questions at other companies
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
- Server ManagementRippling · OARippling interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
- Economical TripAccenture · OAAccenture interview questions
- Minimum Pile Reduction StepsAmerican Express · OAAmerican Express interview questions
- Maximum Production Within PowerZomato / Eternal · OAZomato / Eternal interview questions
- Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
- Compute Walking DistanceTikTok · OATikTok interview questions
- Minimum Tunnel Crossing TimeArcesium · OAArcesium interview questions