Trains the technique from
LeetCode 628Maximum Product of Three NumbersThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A calibration rig logs how far a gauge drifted each shift. drifts[i] is the signed drift for shift i, negative when the gauge fell short and positive when it overshot.
The rig's stress score for three shifts is the product of their three drift values. Pick three shifts at three different positions and return the largest stress score reachable.
Note that two badly negative drifts multiply into a large positive number, so the three biggest values are not always the winning pick.
Example 1
Every value is positive, so the three largest, 3, 5 and 8, give the best score of 120.
Example 2
Taking -9 and -8 together cancels both signs, and pairing them with 2 beats the 1 * 2 * -8 available from the three largest values.
Example 3
Only one triple exists, and its score is negative; that is still the answer.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def largest_triple_drift(drifts: list[int]) -> int:public int largestTripleDrift(int[] drifts)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.