FastPrepShipping Cost Calculator Part 2 - Volume-Tiered Pricing
Problems/Shipping Cost Calculator Part 2 - Volume-Tiered Pricing

Shipping Cost Calculator Part 2 - Volume-Tiered Pricing

Stripe logoStripe● MediumINTERNFULLTIMENEW GRADPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: July 26, 2026 — 🌺 I re-audited the original author-written source and rebuilt this practice version from the available interview report. It is about a 95% match to the available source. The volume-tier model, incremental units in each tier, exact US/CA rules, corrected Canada laptop tier, and worked totals come directly from the author-written report. FastPrep supplies the cross-language String[] adapter, half-open normalized tier representation, bounds, deterministic invalid-input assumptions, and additional tests.

This continues the shipping cost calculator. Now each product's per-unit cost varies by quantity using tiered (volume-discount) pricing.

Inputs:

  • country: the destination country code.
  • items: a String[] of "product,quantity".
  • rules: a String[] of tier rules, each "country,product,minQuantity,maxQuantity,cost". A maxQuantity of * means the tier has no upper limit.

For each item, walk that product's tiers in ascending order. The range of a tier is half-open [minQuantity, maxQuantity), so the tier's capacity is maxQuantity - minQuantity (unbounded if maxQuantity is *). Assign as many remaining units as fit into each tier (the smaller of remaining units and the tier capacity), charge units * cost for those units, and continue until all units are priced. Sum across all items and return the total integer cost.

Function

calculateTieredShippingCost(country: String, items: String[], rules: String[]) → int

Examples

Example 1

country = "US"items = ["mouse,20", "laptop,5"]rules = ["US,mouse,0,*,550", "US,laptop,0,2,1000", "US,laptop,3,*,900", "CA,mouse,0,*,750", "CA,laptop,0,2,1100", "CA,laptop,3,*,1000"]return = 15700

US rates. mouse: 20 x 550 = 11000 (single unbounded tier). laptop (5 units): tier [0,2) holds 2 units at 1000 = 2000, tier [3,*) holds the remaining 3 units at 900 = 2700, laptop total 4700. Grand total 11000 + 4700 = 15700.

Example 2

country = "CA"items = ["mouse,20", "laptop,5"]rules = ["US,mouse,0,*,550", "US,laptop,0,2,1000", "US,laptop,3,*,900", "CA,mouse,0,*,750", "CA,laptop,0,2,1100", "CA,laptop,3,*,1000"]return = 20200

CA rates. mouse: 20 x 750 = 15000. laptop (5 units): tier [0,2) 2 units x 1100 = 2200, tier [3,*) 3 units x 1000 = 3000, laptop total 5200. Grand total 15000 + 5200 = 20200.

Constraints

  • rules entries are "country,product,minQuantity,maxQuantity,cost"; maxQuantity = * means unbounded.
  • Process a product's tiers from lowest to highest minQuantity.
  • The tier range is half-open [minQuantity, maxQuantity); capacity = maxQuantity - minQuantity.
  • Each tier prices min(remaining units, tier capacity) * cost.
  • Return the total cost across all items as an integer.

More Stripe Phone Screen questions

  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026
  • Account Roles With Parent-User InheritancePHONE SCREEN · Seen Nov 2026
  • Merchant Payout Scheduler, Part 3: Hold PeriodsPHONE SCREEN · Seen Nov 2026
  • Merchant Payout Scheduler, Part 1PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • String Interpolation with a Missing-Value ModeMongoDB · PHONE SCREENMongoDB interview questions
  • Dasher Pay with Store Waits and Peak HoursDoorDash · PHONE SCREENDoorDash interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Fixed-Order Task Run Time With CooldownWaymo · PHONE SCREENWaymo interview questions
  • Character Counts with Retried Remote WorkersCoalition · PHONE SCREEN
  • Route Pattern MatcherGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Risk-Priority Detection StoreCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Environment Variable Store and SubstitutionAmazon · PHONE SCREEN

Interview reports that mention this question

  • Stripe SWE Intern Technical Screen Questions Guide
  • Stripe SWE Intern Shipping and BitFont Offer: 1 Experience
  • Stripe New Grad Interview Question Bank: 47 Problems
  • Stripe New Grad Screens and Onsites: 9 Experiences (Part 2 of 2)

Stripe interview experiences

  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public int calculateTieredShippingCost(String country, String[] items, String[] rules) {
      // write your code here
    }
}
Checking account…