← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Stripe coding round for a software engineer role. One problem, but it had enough layers to keep you busy for the whole session.

Questions Asked (1)

Q1

Write a function `compute_total(items, shipping_cost, method)` that calculates the total price of an order. Each item has a price and quantity. Support two pricing modes: one where the unit price decreases linearly as quantity increases (with an optional floor), and another where the total cost for a quantity range is a fixed flat amount regardless of how many units fall in that tier. Add a flat shipping cost at the end.

Algorithms & Data StructuresPricing & MonetizationTechnical Trade-offs
Author's notes

The incremental pricing part was fine, just a loop with a floor check.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and edge cases, then design a clean, extensible solution that separates pricing logic from the total calculation. Implement the two pricing modes as separate functions or strategies, and finally integrate shipping cost while ensuring the code is testable and maintainable.

Pro tip: Demonstrate awareness of real-world pricing systems by discussing how to handle floating-point precision and potential future pricing models, showing you think beyond the immediate problem.

1. Clarify Requirements and Edge Cases

Ask questions to understand the exact behavior: how linear decrease works (slope, floor), how flat tiers are defined, and what happens with zero quantity or negative values. Confirm input formats and expected output type.

2. Design the Data Model and Interfaces

Define how items, pricing modes, and tiers are represented. Consider using a strategy pattern or function pointers to switch between pricing modes cleanly.

3. Implement Pricing Logic

Write separate functions for linear decreasing price and flat tier pricing. Ensure each handles edge cases like quantity below first tier or above last tier.

4. Integrate and Compute Total

Iterate over items, apply the chosen pricing method, sum the costs, and add the flat shipping cost. Return the final total.

5. Test and Validate

Walk through examples, including boundary cases, and discuss how to test the function. Mention potential pitfalls like floating-point rounding.

Key Points to Mention

  • Separation of concerns: pricing logic should be independent of the total calculation.
  • Use of appropriate data structures for tiers (e.g., list of tuples or objects).
  • Handling of edge cases: zero quantity, negative inputs, quantity exceeding defined tiers.
  • Floating-point precision: consider using integers for currency or rounding at the end.
  • Extensibility: how to add new pricing modes without modifying existing code (e.g., strategy pattern).
  • Testing strategy: unit tests for each pricing mode and integration tests for the total function.

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