← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

Stripe technical phone screen for a software engineer role. The problem was a combinatorial optimization thing that felt like it came out of nowhere, way more involved than I expected for a phone screen.

Questions Asked (1)

Q1

You have N factories, each with a list of options where every option has a cost and a distance. You must pick exactly one option per factory. Minimize the total selected costs plus the sum of absolute differences between distances of consecutively selected options. Solve this using backtracking with pruning, and discuss branching order, how you'd estimate lower bounds, and worst-case complexity.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I stared at this for a solid 30 seconds before saying anything.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem as a shortest path in a layered DAG, then explain how backtracking with pruning can be applied. Emphasize the importance of branching order and lower bound estimation to make pruning effective, and discuss worst-case complexity and potential optimizations.

Pro tip: Mention that sorting options within each factory by cost can improve pruning, and that a dynamic programming approach with convex hull trick or divide-and-conquer optimization can solve it in polynomial time, showing depth beyond backtracking.

1. Model the problem

Represent the problem as a layered graph where each factory is a layer and options are nodes. The objective is to find a path from the first to the last layer minimizing the sum of node costs and edge weights (absolute distance differences).

2. Backtracking with pruning

Use recursive backtracking to explore combinations, maintaining the current total cost. At each step, compute a lower bound on the remaining cost and prune if current cost + lower bound >= best found so far.

3. Branching order

Order the options at each factory to explore promising ones first. A good heuristic is to sort by cost ascending, or by a combination of cost and distance compatibility with the previous selection.

4. Lower bound estimation

For the remaining factories, compute a lower bound by summing the minimum possible cost for each remaining factory (ignoring distance transitions) plus a lower bound on the distance penalties, such as the minimum absolute difference between any option in the current factory and any option in the next factory.

5. Complexity analysis

Worst-case complexity is exponential: O(M^N) where M is the maximum number of options per factory. With pruning, average case can be much better, but worst-case remains exponential. Mention that dynamic programming can achieve O(N * M^2) or better with optimizations.

Key Points to Mention

  • The problem is equivalent to finding a shortest path in a layered DAG.
  • Backtracking with pruning is a branch-and-bound algorithm; the lower bound must be admissible (never overestimate) to guarantee optimality.
  • Branching order affects pruning efficiency; try options with lower cost and closer distances first.
  • Lower bound can be computed as the sum of minimum costs of remaining factories plus a lower bound on transition costs (e.g., 0 or minimum possible distance difference).
  • Worst-case time complexity is O(M^N), but with pruning it can be much faster in practice.
  • Dynamic programming with state (factory index, chosen option) can solve it in O(N * M^2), and can be optimized further with convex hull trick or divide-and-conquer if the cost function has special structure.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.