FastPrepMaximize Minimum Deployment Difficulty

Maximize Minimum Deployment Difficulty

JP Morgan Chase logoJP Morgan Chase● MediumFULLTIMEOA
Learn

Problem statement

Distribute every module among three nonempty servers. Afterward, one difficulty d1, d2, and d3 is selected from servers 1, 2, and 3. The selected score is |d1-d2| + |d2-d3|.

For a distribution, its deployment difficulty is the minimum selected score over all allowed choices. Return the largest deployment difficulty attainable by a distribution.

Function

maximizeMinimumDeploymentDifficulty(difficulty: int[]) → int

Examples

Example 1

difficulty = [1,2,3]return = 3

Case 1 exercises the documented deterministic contract.

Example 2

difficulty = [1,2,3,7,8,15,20,21]return = 24

Case 2 exercises the documented deterministic contract.

Example 3

difficulty = [5,5,5]return = 0

Case 3 exercises the documented deterministic contract.

Constraints

  • 3 <= difficulty.length <= 200000.
  • 0 <= difficulty[i] <= 10^8.

More JP Morgan Chase problems

See JP Morgan Chase hiring insights
public int maximizeMinimumDeploymentDifficulty(int[] difficulty) {
    // Write your code here.
}
difficulty[1,2,3]
expected3
Checking account…