JPMorganChase OA
Anonymous User
446

Maximize Minimum Deployment Difficulty

You are given an integer array difficulty of length n, where difficulty[i] represents the difficulty of the i-th software module.

You need to distribute all modules among three different servers.

The distribution must satisfy:

  • Each server must contain at least one module.
  • Every module must be assigned to exactly one server.

After the modules are distributed, one module is selected from each server:

  • Let d1 be the difficulty of the selected module from Server 1.
  • Let d2 be the difficulty of the selected module from Server 2.
  • Let d3 be the difficulty of the selected module from Server 3.

The deployment difficulty for the selected modules is defined as:

|d1 - d2| + |d2 - d3|

For a particular distribution, define its minimum deployment difficulty as the minimum possible value of the above expression among all possible choices of one module from each server.

Your goal is to find a distribution of modules among the three servers that maximizes the minimum deployment difficulty.

Return the maximum possible minimum deployment difficulty.

Comments (3)