−65% Most banks now $169 $59.
Coding · 8 min read

Stripe's 3-Part Shipping Cost Coding Question

Stripe coding rounds are rarely about exotic algorithms. They hand you a real money problem and keep changing the pricing rules, exactly like a production billing system. This shipping-cost question grows across three parts. Here is the full question, a Java solution for each part, and the rubric.


The question

Given an order (a country and a list of items with quantities) and a shipping-cost table, compute the total shipping cost. Then the pricing model changes twice.

order = { country: "US", items: [
  { product: "mouse",  quantity: 20 },
  { product: "laptop", quantity: 5  } ] }

// Part 1: flat per-unit cost per product, per country
shippingCost(order_US) == 16000
shippingCost(order_CA) == 20500

Part 1 · Flat per-unit pricing

Look up the country's table, multiply each item's unit cost by its quantity, and sum. The whole question hinges on the shape you give this table, because Parts 2 and 3 will replace a flat number with a list of brackets.

import java.util.*;

class Shipping {
    static class LineItem { String product; int quantity; }
    static class Order { String country; List<LineItem> items; }

    // Part 1: costs = country -> (product -> unit cost)
    int shippingCost(Order order, Map<String, Map<String, Integer>> costs) {
        Map<String, Integer> table = costs.get(order.country);
        if (table == null) throw new IllegalArgumentException("unknown country: " + order.country);
        int total = 0;
        for (LineItem item : order.items) {
            Integer unit = table.get(item.product);
            if (unit == null) throw new IllegalArgumentException("no price for " + item.product);
            total += unit * item.quantity;
        }
        return total;
    }
}

US check: mouse 20 x 550 = 11000, laptop 5 x 1000 = 5000, total 16000. The guard clauses matter; Stripe watches how you handle a missing country or product.

Part 2 · Tiered (incremental) pricing

Now price decreases with quantity through progressive brackets, like tax bands. For a laptop at quantity 5 with brackets [0-2] at 1000 and [3+] at 900, the first 2 units cost 1000 each and the next 3 cost 900 each: 2000 + 2700 = 4700. Model each product as an ordered list of tiers and walk the cumulative quantity.

static class Tier { int minQ; Integer maxQ; int cost; }   // maxQ == null means unbounded

int shippingCostTiered(Order order, Map<String, Map<String, List<Tier>>> costs) {
    Map<String, List<Tier>> table = costs.get(order.country);
    int total = 0;
    for (LineItem item : order.items) total += incrementalCost(table.get(item.product), item.quantity);
    return total;
}

// Each unit is charged at the rate of the cumulative band it falls into.
private int incrementalCost(List<Tier> tiers, int qty) {
    int cost = 0, covered = 0;
    for (Tier t : tiers) {
        if (covered >= qty) break;
        int upper = (t.maxQ == null) ? qty : Math.min(qty, t.maxQ);
        int units = upper - covered;             // units that fall in this band
        if (units > 0) cost += units * t.cost;
        covered = upper;
    }
    return cost;
}

US laptop at qty 5: band [0-2] gives 2 x 1000, band [3+] gives 3 x 900, total 4700; plus mouse 11000 makes 15700. The key move is tracking covered so each unit is counted exactly once.

Part 3 · Fixed and incremental tiers together

Each tier now carries a type. An incremental tier charges per unit as in Part 2. A fixed tier charges a flat amount for landing in that band, regardless of how many units fall in it. Because Part 2 already iterates bands cleanly, this is one branch.

enum Type { INCREMENTAL, FIXED }
static class Tier2 { int minQ; Integer maxQ; int cost; Type type; }

private int cost(List<Tier2> tiers, int qty) {
    int cost = 0, covered = 0;
    for (Tier2 t : tiers) {
        if (covered >= qty) break;
        int upper = (t.maxQ == null) ? qty : Math.min(qty, t.maxQ);
        int units = upper - covered;
        if (units > 0) cost += (t.type == Type.FIXED) ? t.cost : units * t.cost;
        covered = upper;
    }
    return cost;
}

A fixed tier adds its flat cost once when any units reach the band; an incremental tier adds per unit. The same loop now serves all three pricing models, which is exactly the generalization the interviewer is checking for.

How Stripe scores it

Dimension Weak Strong
Data modelHardcodes a flat number, rewrites at Part 2Models pricing as ordered tiers from the start
CorrectnessOff-by-one across band boundariesEach unit counted once via a cumulative cursor
GeneralizationSpecial-cases fixed vs incremental everywhereOne branch inside a shared tier loop
Money handlingFloats and rounding bugsInteger minor units, explicit on currency
Edge casesCrashes on unknown product or countryGuard clauses and empty-tier handling
ClarityDense, unnamed logicReadable, shippable, well-named

This is one question of 75 pages

Get the full Stripe question bank

The full Stripe bank is 75 pages of real coding rounds, each problem with its escalating parts and a rubric, compiled from people familiar with the process and cross-verified across sources.

Stripe interview FAQ

What does the Stripe coding interview ask?+

Practical problems modeled on Stripe's own domain: pricing, invoicing, payments, and parsing structured input. One problem is extended across parts as the rules get more realistic, testing whether your data model absorbs change.

Is the Stripe interview LeetCode-style?+

Less than most. Stripe favors real-world modeling, clean handling of money and edge cases, and code you would be comfortable shipping. Integration-style and API rounds are common too.

How is the Stripe coding round scored?+

On correctness against the worked examples, how cleanly your Part 1 data model extends to tiered and fixed pricing, money and edge-case handling, and code clarity. Rewriting at each part is the failure mode.

Where can I find real Stripe interview questions?+

Pichup maintains a 75-page Stripe question bank compiled from people familiar with the process, with the coding rounds, their parts, and rubrics. The question in this guide is one of them.