FastPrepWeighted Raffle with Repeat Penalties

Weighted Raffle with Repeat Penalties

Bloomberg LP logoBloomberg LP● MediumFULLTIMEONSITE INTERVIEW
Learn

Problem statement

Participant i entered entryCounts[i] times and receives total raffle weight 1 / entryCounts[i]. Normalize all weights into probabilities.

Return each probability in input order as a reduced numerator/denominator string.

Function

raffleProbabilities(entryCounts: int[]) → String[]

Examples

Example 1

entryCounts = [2,3,1]return = ["3/11","2/11","6/11"]

Weights 1/2, 1/3, and 1 normalize against total 11/6.

Constraints

  • 1 <= entryCounts.length <= 12.
  • 1 <= entryCounts[i] <= 30.
  • The least common multiple fits in signed 64-bit range.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public String[] raffleProbabilities(int[] entryCounts) {
  // Write your code here.
}
entryCounts[2,3,1]
expected["3/11", "2/11", "6/11"]
Checking account…