FastPrepMinimum Bonus Projects

Minimum Bonus Projects

Wells Fargo logoWells Fargo● MediumFULLTIMEOA
Learn

Problem statement

You are given an array errorScores of nonnegative employee error scores and two reductions selectedReduction and otherReduction, where selectedReduction > otherReduction.

In one bonus-project operation, choose one employee. That employee's score decreases by selectedReduction, while every other employee's score decreases by otherReduction. A score that would become negative is treated as 0.

Return the minimum number of operations required to reduce every score to 0.

Function

minimumBonusProjects(errorScores: long[], selectedReduction: long, otherReduction: long) → long

Examples

Example 1

errorScores = [6,4,1]selectedReduction = 4otherReduction = 1return = 3

Three operations suffice. With only two operations, the total number of extra selected reductions required is greater than two.

Example 2

errorScores = [5]selectedReduction = 2otherReduction = 0return = 3

The sole employee must be selected three times.

Example 3

errorScores = [3,3]selectedReduction = 3otherReduction = 1return = 2

Select each employee once. Each receives one reduction of 3 and one reduction of 1, which is enough to reach zero.

Example 4

errorScores = [0,0]selectedReduction = 5otherReduction = 1return = 0

Every score is already zero.

Constraints

  • 1 <= errorScores.length <= 10^5.
  • 0 <= errorScores[i] <= 10^9.
  • 0 <= otherReduction < selectedReduction <= 10^9.

More Wells Fargo problems

See Wells Fargo hiring insights
public long minimumBonusProjects(long[] errorScores, long selectedReduction, long otherReduction) {
  // write your code here
}
errorScores[6,4,1]
selectedReduction4
otherReduction1
expected3
Checking account…