Compute Invoice Line Totals Under Graduated and Volume Tiered Pricing

Last updated: November 29, 2026

Quick Overview

Given a quantity and a list of price tiers (each with an upper bound, a per-unit amount and a flat fee, all in integer cents), compute the charge under graduated pricing and under volume pricing.

Stripe
Coding & Algorithms
Software Engineer
Stripe
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a quantity and a list of price tiers (each with an upper bound, a per-unit amount and a flat fee, all in integer cents), compute the charge under graduated pricing and under volume pricing.

Tiered pricing is a core Stripe Billing concept, and the two modes are a common source of merchant confusion, which makes it a natural warm-up in a Stripe coding screen. The interviewer checks that you keep money in integer minor units, get the tier boundaries exactly right and explain the difference between the modes clearly.

What the Interviewer Expects
  • Represent money as integer cents, never floats
  • Get inclusive upper bounds right (quantity 10 with `up_to=10` stays in tier one)
  • Graduated: charge each slice of quantity at its own tier and add the flat fee of every tier touched
  • Volume: price the entire quantity at the single tier it lands in
  • Handle the open-ended final tier (`up_to=None`) and zero quantity
Key Topics to Cover
arrays
billing
integer money
boundary conditions
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you produce an itemized breakdown for the invoice PDF?
  • How would you validate a tier list (sorted, last tier unbounded, no gaps)?
  • What should happen if the price changes mid-period with usage already recorded?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Tiers are a list of (up_to, unit_amount, flat_amount) sorted by up_to, with the last tier's up_to set to None. Return the total in cents for a given quantity and mode in `{"graduated", "vo...

High-Level Design

Volume pricing is a lookup: find the first tier whose bound covers the quantity and charge quantity * unit + flat. Graduated pricing walks tiers with a running prev boundary; each tier contributes...


Submit Your Answer
Markdown supported