Pressure-Isolation Shutdown Order
Reported by candidates from Intuit's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks a first attempt on this Intuit problem, reported in September 2026, is thinking about which valve to shut down first. It's a Burst Balloons variant with a twist: you also count how many orders hit the max. The hinted tag is sorting, but that's misleading. This is interval DP, and n is capped at 200, so O(n^3) fits. If you blank on the recurrence during the OA, StealthCoder is the safety net that reads the problem and hands you a working solution while you stay in control.
The problem
An offshore processing platform has n valves in a line. Valve i has signed pressure coefficient coefficients[i]. Permanent boundary regulators with coefficients leftBoundary and rightBoundary stand immediately outside the line and are never shut down. Shut down every valve exactly once. When valve i is shut down, let x and y be the coefficients of its nearest valves or boundary regulators that are still active on its left and right. This shutdown adds x * coefficients[i] * y to the total stability score. Valve i is then removed, so later shutdowns may have different neighbors. Return a two-element array: the maximum possible total stability score, followed by the number of distinct shutdown orders that attain that maximum. Report the number of orders modulo 10^9 + 7. Two orders are distinct when their valve-index sequences differ. Function maximizeStabilityAndCount(coefficients: int[], leftBoundary: int, rightBoundary: int) → long[] Examples Example 1 coefficients = [3] leftBoundary = 2 rightBoundary = 5 return = [30,1] There is one shutdown order. Its only step contributes 2 * 3 * 5 = 30. Example 2 coefficients = [1,1] leftBoundary = 1 rightBoundary = 1 return = [2,2] Either valve can be shut down first. Both orders score 1 + 1 = 2, so there are two maximizing orders. Example 3 coefficients = [1,2] leftBoundary = 1 rightBoundary = 1 return = [4,1] Closing the first valve before the second scores 1 * 1 * 2 + 1 * 2 * 1 = 4. The other order scores 1 * 2 * 1 + 1 * 1 * 1 = 3. Constraints 1 <= coefficients.length <= 200. -1000 <= coefficients[i], leftBoundary, rightBoundary <= 1000. Use signed 64-bit arithmetic for stability scores and the returned score. The returned count is reduced modulo 10^9 + 7.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Flip the thinking. Pick the LAST valve k to shut down in the interval (i, j). At that moment its neighbors are the fixed boundaries of the interval, so the score is vals[i] * c[k] * vals[j], plus the best of the left and right subintervals. Pad the array with leftBoundary and rightBoundary, then fill dp[i][j] by increasing length. For counting, keep a second table cnt[i][j]. For each k that ties the best score, add cnt[i][k] * cnt[k][j] * C(len-1, leftSize), where the binomial interleaves the two independent sub-orders. That binomial is the part people forget, and it's the usual wrong answer. Precompute Pascal's triangle mod 1e9+7. Initialize the best to a very negative long, since scores can be negative. Empty intervals have score 0 and count 1. Check Example 2 gives 2. If the live OA freezes you on the combinatorics, StealthCoder is the hedge.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Pressure-Isolation Shutdown Order 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Intuit's OA.
Intuit reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Pressure-Isolation Shutdown Order FAQ
What's the trick in the Pressure-Isolation Shutdown Order problem?+
Think in reverse. Choose the last valve removed in each interval, so its neighbors are the interval boundaries and the left and right subproblems become independent. That gives clean interval DP in O(n^3), which fits n up to 200.
How do I count the number of optimal orders?+
Keep a count table beside the score table. For every split k that ties the max, add left count times right count times the binomial C(totalValves-1, leftValves). The binomial counts the ways to interleave the two independent shutdown sequences. Take everything mod 1e9+7.
Is sorting actually useful here?+
No. The sorting hint is misleading. Order matters because removing a valve changes neighbors, so you can't sort and greedily pick. Greedy fails on Example 3 style cases. Use interval DP with padded boundaries instead.
What edge cases break most first attempts?+
Negative coefficients, so initialize the best score to a very negative value, not zero. Also use 64-bit integers for products, and handle single-element and empty subintervals with score 0 and count 1. Verify with the three examples before submitting.
How do I prepare for this in 48 hours?+
Write Burst Balloons from scratch until the last-removed idea is automatic. Then add the count table and the Pascal's triangle binomial. Test on the three examples by hand. Don't spend time on sorting drills for this one.