Factory Cost - Min-Cost Path Skipping One Stage
See Stripe hiring insightsThis continues the factory min-cost-path problem. stages[i] is a list of factory choices for stage i, each choice being [build_cost, position] on a 1-D line. The total cost of a selection is sum(chosen build_cost) + sum(|pos_i - pos_{i+1}|) over consecutive chosen factories, with no inbound transit for the first chosen factory.
Now you must remove exactly one stage before selecting. After a stage is removed, the remaining stages are taken in order, and the transit cost is measured across the gap — between the factory chosen in the stage before the removed one and the factory chosen in the stage after it.
Try removing every stage and return the minimum achievable total. If there are 1 or fewer stages, return 0 (after removal there is nothing left to connect, so transit is 0).
stages = [[[10,0],[20,2]], [[100,5]], [[15,1],[25,3]], [[5,2],[15,0]]] return = 32
stages = [[[10,0],[20,2]], [[100,5]]] return = 10
stages[i]is a non-empty list of[build_cost, position]integer choices.- Exactly one stage is removed before selecting one factory per remaining stage.
- Transit across the removed stage's gap is measured between the chosen factories of the stages immediately before and after it.
- If
stages.length <= 1, return0. - Either the first or last stage may be the one removed.
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 3 - Decode Run-Length-Encoded RowsONSITE INTERVIEW · Seen Jun 2026
- Record Linkage Part 3 - Full Connected ComponentPHONE SCREEN · Seen Jun 2026
- Shipping Cost Calculator Part 3 - Mixed Fixed/Incremental TiersONSITE INTERVIEW · Seen Jun 2026
- Transaction Fee Calculator - Per-Merchant Volume DiscountPHONE SCREEN · Seen Jun 2026
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 2 - Render a WordONSITE INTERVIEW · Seen Jun 2026
- HTTP Accept-Language with Quality Scores (q-factors)ONSITE INTERVIEW · Seen Jun 2026
public int findMinimumCostSkipOne(int[][][] stages) {
// write your code here
}