Problem

Fair Prize Distribution

Learn this problem
AmazonFULLTIMEOA
See Amazon hiring insights

Problem statement

A coding challenge has n participants. Participant i earned score points[i]. There are m available prizes, and values[j] is the value of the j-th prize.

Assign one prize value to each participant using the available prize multiset such that:

  • Participants with the same score receive the same prize value.
  • Participants with higher scores receive strictly higher prize values than participants with lower scores.

If multiple fair distributions are possible, return the lexicographically smallest distribution in the original participant order.

Function

findFairDistribution(points: int[], values: int[]) → int[]

Examples

Example 1

points = [5,5,5]values = [2,2,2,3,3,3]return = [2,2,2]

All participants have the same score, so they must receive equal prize values. [2,2,2] is lexicographically smaller than [3,3,3].

Constraints

  • 1 <= points.length, values.length <= 2 * 10^5
  • 1 <= points[i], values[i] <= 10^9

More Amazon problems

drafts saved locally
public int[] findFairDistribution(int[] points, int[] values) {
  // write your code here
}
points[5,5,5]
values[2,2,2,3,3,3]
expected[2,2,2]
checking account