← Stripe Interview Insights

Stripe·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Stripe coding screen for a software engineer role, one meaty design-your-own-pricing problem that looked deceptively clean on the surface. The dual-method requirement is where things got interesting.

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 methods: one where the unit price decreases linearly as quantity increases (with an optional floor), and one where each quantity tier maps to a fixed total price regardless of how many units fall in that range. Add a flat shipping cost at the end.

Algorithms & Data StructuresTechnical Trade-offsPricing & Monetization
Author's notes

The incremental pricing side was fine, just a running sum 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 outline a modular design with separate functions for each pricing method. Implement the core logic with clear variable names and handle floating-point precision carefully. Finally, discuss trade-offs and potential optimizations.

Pro tip: Demonstrate awareness of real-world pricing systems by mentioning the importance of rounding rules and avoiding floating-point errors, perhaps using integer cents or Decimal. Also, proactively discuss how to extend the function for future pricing methods.

1. Clarify Requirements

Ask questions to understand the exact behavior: What does 'linearly decreases' mean? Is the floor a minimum unit price? How are tiers defined for the fixed total price method? Are there any constraints on input sizes?

2. Design the Interface

Define the function signature and data structures for items, shipping cost, and method. Consider using an enum or string for method selection and a clear structure for tier definitions.

3. Implement Pricing Methods

Write separate helper functions for each pricing method. For linear pricing, compute unit price based on quantity, apply floor if provided. For tiered pricing, determine which tier the quantity falls into and use the fixed total price for that tier.

4. Handle Edge Cases and Precision

Address edge cases like zero quantity, negative prices, and floating-point precision. Use integer arithmetic (e.g., cents) or Decimal to avoid rounding errors, and apply consistent rounding rules.

5. Test and Discuss Trade-offs

Walk through test cases, including boundary conditions. Discuss trade-offs between simplicity and extensibility, and how the design could accommodate new pricing methods.

Key Points to Mention

  • Modular design with separate functions for each pricing method to adhere to the single responsibility principle.
  • Use of integer cents or Decimal to avoid floating-point precision issues in monetary calculations.
  • Clear handling of edge cases such as zero quantity, negative values, and missing floor.
  • Discussion of time and space complexity, noting that the solution is O(n) for n items.
  • Extensibility: how to add new pricing methods without modifying existing code (e.g., strategy pattern).
  • Real-world considerations: rounding rules, currency handling, and potential for bulk discounts.

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