Stripe Phone Screen | Senior Software Engineer Interview
Summary
I had a phone screen interview with Stripe for a Senior Software Engineer role. The interview focused on a two-part problem involving shipping cost calculation, which I managed to solve within the given time. I'm uncertain about the outcome, but I'll wait and see.
Full Experience
I recently had a phone screen interview for a Senior Software Engineer position at Stripe. The interview presented a coding challenge in two parts, both revolving around calculating shipping costs based on varying parameters. I successfully solved the first part, which involved a basic calculation using fixed product costs per country, in about 20 minutes. The second part introduced more complexity, requiring me to handle quantity-based discounts where costs were defined in slabs. I managed to tackle this part as well before we ran out of time. The interviewer mentioned I needed to solve as many parts as possible within 45 minutes, which I did. However, I have a feeling I might not receive a callback, but I'm keeping my options open.
Interview Questions (2)
You are given two JavaScript objects: order and shipping. You need to calculate the total shipping cost for the given country in the order object.
order = { "country": "US", "items": [ {"product": "mouse", "quantity": 5}, {"product": "laptop", "quantity": 2} ] }
shipping = { "US": [ {"product": "mouse", "cost": 500}, {"product": "laptop", "cost": 1000} ], "CA": [ {"product": "mouse", "cost": 700}, {"product": "laptop", "cost": 1200} ] }
In this example, the total shipping cost would be 5 * 500 + 2 * 1000 = 4500.
Extend the previous problem. Now, if discounts are given for different quantities, how would you calculate the shipping cost? The shipping object has been modified to include quantity-based cost slabs.
shipping = {
"CA": [
{"product": "mouse", "cost": 500},
{"product": "laptop", "cost": 1000}
],
"US": [
{"product": "mouse",
"cost": [{
minQuantity:0,
maxQuantity:2,
cost: 200
},
{
minQuantity:3,
maxQuantity:null,
cost: 700
}
]
},
{"product": "laptop",
"cost": [{
minQuantity:0,
maxQuantity:null,
cost: 700
}
]
}
]
}
Using the original order (5 mice, 2 laptops in US), the shipping cost would be (3 * 200 + 2 * 700) + (2 * 700) = 600 + 1400 + 1400 = 3400. (Note: The provided example calculation 3 * 200 + 2 * 700 + 2 * 700 implicitly assumes 5 mice, where 3 fall into the minQuantity:3 slab and 2 into the minQuantity:0, maxQuantity:2 slab, which is a bit ambiguous; a more direct interpretation would be finding the *single* applicable slab for the *total* quantity of 5 mice, which is minQuantity:3, cost: 700, making it 5 * 700. However, following the example calculation 3 * 200 + 2 * 700 + 2 * 700, it implies a weighted average or a specific interpretation of how to apply multiple slabs for a single quantity. For clarity, I will assume finding the *single best matching slab* for the total quantity based on minQuantity being less than or equal to item quantity and maxQuantity being greater than or equal to item quantity, or null.)