Reported September 2026
Visagreedy

Maximum Three-Server Difficulty Score

Reported by candidates from Visa's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Visa OA. Under 2s to a working solution.
Founder's read

The Visa OA reported in September 2026 hands you a score formula, |d1 - d2| + |d2 - d3|, and three servers that each need at least one module. It looks like a partitioning puzzle. It isn't. Strip the server story and you're picking three distinct elements from an array to maximize a two-term expression. That's a sorting or min/max problem, and it's solvable in one pass. If you blank on the reduction during the live assessment, StealthCoder runs invisibly as a safety net and shows you the approach. Read the trick below first and you probably won't need it.

The problem

You are given an integer array difficulty, where each value is the difficulty of one module.
Distribute all modules among three labeled servers. Every module must be assigned to exactly one server, and each server must receive at least one module. Then choose one module from each server. Let their difficulties, in server order, be d1, d2, and d3.
The score is |d1 - d2| + |d2 - d3|. Return the maximum score obtainable over all valid distributions and choices.
FastPrep practice interpretation: The explicit two-term formula and the reported extreme-value strategy determine the judged score. The selected modules must be three distinct array elements, although equal difficulty values are allowed.

Function
maximumDifficultyScore(difficulty: int[]) → long

Examples
Example 1
difficulty = [1,4,7,10]
return = 15
Place difficulties 1, 10, and 4 on servers one, two, and three. The score is |1 - 10| + |10 - 4| = 9 + 6 = 15.
Example 2
difficulty = [5,5,5]
return = 0
Every selected difficulty is 5, so both absolute differences are 0.
Example 3
difficulty = [2,3,100]
return = 195
Use 100 as d2 and the other two values as the endpoints. The score is |2 - 100| + |100 - 3| = 98 + 97 = 195.

Constraints
3 <= difficulty.length <= 100000
1 <= difficulty[i] <= 10^9

Reported by candidates. Source: FastPrep

Pattern and pitfall

Any three distinct indices can go on three servers, and the leftover modules can be dumped on any server, so the distribution is a red herring. You only choose three elements and an order. The middle value d2 appears in both terms. To maximize the score, make d2 an extreme and the endpoints the opposite extreme. Case one: d2 is the max, so the score is 2*max - d1 - d3, where d1 and d3 are the two smallest. Case two: d2 is the min, so the score is d1 + d3 - 2*min, with d1 and d3 the two largest. Sort the array, or track the top two and bottom two in one pass, then take the larger of the two cases. Check example 3: 2*100 - 2 - 3 = 195. Pitfall: you must use three distinct positions, so don't reuse the same element. Also use 64-bit math, since values reach 10^9 and doubling overflows 32-bit ints.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Maximum Three-Server Difficulty Score cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Visa's OA.

Visa reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Three-Server Difficulty Score FAQ

What's the trick in the Visa Maximum Three-Server Difficulty Score problem?+

Ignore the server distribution. Any three distinct elements can be placed on three servers. The score is maximized by putting an extreme value in the middle slot and the opposite extremes on the ends. Compare two cases: max in the middle, or min in the middle, and return the larger.

How hard is this OA question really?+

Easier than it reads. The wording is long, but the solution is a sort plus two formulas. If you spot that d2 appears twice in the score, you're done in a few minutes. The hard part is not overthinking the distribution step.

Do I need to worry about overflow?+

Yes. Values go up to 10^9 and the score can be about 2*10^9 or more, which overflows a 32-bit signed int. The function returns long for that reason. Cast to 64-bit before doing the arithmetic, especially in Java, C++, or C#.

Can I solve it without sorting?+

Yes. One pass tracking the two smallest and two largest values gives O(n) time and O(1) space. Sorting is O(n log n), which is fine for n up to 100000. Sorting is simpler and less error-prone, so use it unless you're asked for linear time.

How do I prepare for this in 48 hours?+

Practice reducing wordy problems to the core operation. Here that means noticing the constraints don't restrict choices. Work through the three examples by hand, including the all-equal case [5,5,5] giving 0. Then code the sorted version and test it on arrays of exactly three elements.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Visa.

OA at Visa?
Invisible during screen share
Get it