Limited Time Offer:Up to 20% off Hello Interview Premium
Up to 20% off Hello Interview Premium 🎉
Hello Interview
Your Dashboard
System Design
Code
Low Level Design
Behavioral
AI Coding
New
ML System Design
Salary Negotiation
Interview Guides
Blog
System Design
Low Level Design
AI Coding
Behavioral
New
Interview Questions
Success Stories
System Design
Low-Level Design
New
Ask The Community
Discord
Mock Interviews
1:1 Mentorship
Refer a Friend
Pricing
Sign in / Sign up
Search
⌘K
Pricing

Tutor

Calculate Total Shipping Cost for an Order

Given an order containing items and quantities, and a shipping cost structure, implement a function to calculate the total shipping cost. The shipping cost structure should support country-specific pricing, quantity-based pricing tiers, and both incremental (per-unit) and fixed (flat-rate) cost calculation methods.

Asked at:

Stripe


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Company
​
Level
All Regions
Region

Mid March, 2026

Stripe

Mid-level

Given an order and shipping cost, calculate the total price. For example: Part 1: Order: { "country": "US", // or "CA" for the CA order "items": [ {"product": "mouse", "quantity": 20}, {"product": "laptop", "quantity": 5} ] } Shipping Cost: { "US": [ {"product": "mouse", "cost": 550}, {"product": "laptop", "cost": 1000} ], "CA": [ {"product": "mouse", "cost": 750}, {"product": "laptop", "cost": 1100} ] } calculate_shipping_cost(order_us, shipping_cost) == 16000 calculate_shipping_cost(order_ca, shipping_cost) == 20500 Part 2 The price is not fixed, (i.e. decreases with the quantity). For example: Shipping Cost: { "US": [ { "product": "mouse", "costs": [ { "minQuantity": 0, "maxQuantity": null, "cost": 550 } ] }, { "product": "laptop", "costs": [ { "minQuantity": 0, "maxQuantity": 2, "cost": 1000 }, { "minQuantity": 3, "maxQuantity": null, "cost": 900 } ] } ], "CA": [ { "product": "mouse", "costs": [ { "minQuantity": 0, "maxQuantity": null, "cost": 750 } ] }, { "product": "laptop", "costs": [ { "minQuantity": 0, "maxQuantity": 2, "cost": 1100 }, { "minQuantity": 3, "maxQuantity": null, "cost": 1000 } ] } ] } calculate_shipping_cost(order_us, shipping_cost) == 15700 calculate_shipping_cost(order_ca, shipping_cost) == 20200 Part 3 There are two cost calculation methods: incremental (same as Question 2) and fixed (the total price is the same within a range, regardless of the quantity). For example: Shipping Cost: { "US": [ { "product": "mouse", "costs": [ { "type": "incremental", "minQuantity": 0, "maxQuantity": null, "cost": 550 } ] }, { "product": "laptop", "costs": [ { "type": "fixed", "minQuantity": 0, "maxQuantity": 2, "cost": 1000 }, { "type": "incremental", "minQuantity": 3, "maxQuantity": null, "cost": 900 } ] } ], "CA": [ { "product": "mouse", "costs": [ { "type": "incremental", "minQuantity": 0, "maxQuantity": null, "cost": 750 } ] }, { "product": "laptop", ‍‍‍‍‍‍‌‌‌‌‌‍‌‍‍‌‌‍‍ "costs": [ { "type": "fixed", "minQuantity": 0, "maxQuantity": 2, "cost": 1100 }, { "type": "incremental", "minQuantity": 3, "maxQuantity": null, "cost": 1000 } ] } ] } calculate_shipping_cost(order_us, shipping_cost) == 14700 calculate_shipping_cost(order_ca, shipping_cost) == 19100

Your account is free and you can post anonymously if you choose.

Hello Interview Premium

Recent interview questions
System Design Guided Practice
Exclusive content
Learn More
Questions
Meta SWE Interview QuestionsAmazon SWE Interview QuestionsGoogle SWE Interview QuestionsOpenAI SWE Interview QuestionsEngineering Manager (EM) Interview Questions
Learn
Learn System DesignLearn DSALearn BehavioralLearn ML System DesignLearn Low Level DesignGuided Practice
Links
FAQPricingGift PremiumHello Interview Premium
Legal
Terms and ConditionsPrivacy PolicySecurity
Contact
About UsProduct Support

7511 Greenwood Ave North Unit #4238 Seattle WA 98103


© 2026 Optick Labs Inc. All rights reserved.