FastPrepShipping Cost Calculator Part 1 - Fixed Per-Unit Price
Problems/Shipping Cost Calculator Part 1 - Fixed Per-Unit Price

Shipping Cost Calculator Part 1 - Fixed Per-Unit Price

Stripe logoStripe● EasyINTERNFULLTIMENEW 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 order structure, country lookup, product quantities, fixed per-unit shipping prices, and worked US/CA totals come directly from the author-written report. An author reply also confirms a map-based order and shipping-cost input. FastPrep supplies the cross-language String[] adapter, integer bounds, deterministic invalid-input assumptions, and additional tests.

Calculate the total shipping cost for an online order. The cost depends on the destination country and the product, and in this first version every product has a single fixed cost per unit.

Inputs:

  • country: the destination country code for the order.
  • items: a String[] where each entry is "product,quantity".
  • rules: a String[] where each entry is "country,product,cost" giving the fixed per-unit cost of a product in a country.

For each ordered item, multiply its quantity by the per-unit cost for that product in the order's country, and sum across all items. Return the total as an integer.

Function

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

Examples

Example 1

country = "US"items = ["mouse,20", "laptop,5"]rules = ["US,mouse,550", "US,laptop,1000", "CA,mouse,750", "CA,laptop,1100"]return = 16000

Using US rates: mouse 20 x 550 = 11000, laptop 5 x 1000 = 5000. Total = 16000.

Example 2

country = "CA"items = ["mouse,20", "laptop,5"]rules = ["US,mouse,550", "US,laptop,1000", "CA,mouse,750", "CA,laptop,1100"]return = 20500

Using CA rates: mouse 20 x 750 = 15000, laptop 5 x 1100 = 5500. Total = 20500.

Constraints

  • items entries are "product,quantity" with integer quantity.
  • rules entries are "country,product,cost" with integer cost (per unit).
  • Use the per-unit cost for the order's country and each product.
  • Total = sum over items of quantity * cost; return 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

  • SimpleRDD Word CountDatologyAI · PHONE SCREEN
  • Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
  • Count Complete Toll JourneysOnePay · PHONE SCREENOnePay interview questions
  • Wordle Feedback with Duplicate LettersScale AI · PHONE SCREENScale AI interview questions
  • 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

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 Coding Patterns, 2026 Guide
  • 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
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public int calculateShippingCost(String country, String[] items, String[] rules) {
      // write your code here
    }
}
Checking account…