Get Final Price
Reported by candidates from Doordash's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
DoorDash hit you with a discount problem in October 2024, and it's deceptively simple until you hit the edge cases. You're calculating final price after applying coupon codes and bulk discounts, which sounds straightforward but catches people who don't think through the order of operations. The core challenge is figuring out which discount applies first, how they stack, and whether there are minimums or caps. This is the kind of problem where your first instinct might be wrong, and that's where StealthCoder becomes your safety net if you blank on the logic mid-OA.
Pattern and pitfall
The pattern here is simulation with conditional logic and careful bookkeeping. You're taking an input price and a set of discount rules, then applying them in the right sequence to get the final answer. The trick is that most candidates apply discounts in the wrong order or forget to check constraints like minimum purchase amounts or maximum discount limits. The algorithm isn't complex, but the implementation is fragile. You need to parse discount objects, validate conditions, apply math in the correct order, and return the result. It's not about optimization, it's about correctness. If you get stuck mid-OA and your logic is tangled, StealthCoder reads the problem fresh and gives you the pattern to refactor quickly.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Get Final Price cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Doordash's OA.
Doordash reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Get Final Price FAQ
Do discounts stack or does only one apply?+
The problem doesn't specify in what you provided, so assume you need to read the rules carefully during the OA. Usually coupon codes and bulk discounts don't both apply at full value. Check whether the problem says 'apply the best discount' or 'apply all applicable discounts' and handle accordingly.
What's the most common mistake on this type of problem?+
Applying discounts in the wrong order. If a coupon gives 20% off and bulk gives a flat $5 off, does order matter. Calculate both ways mentally before coding. Also forgetting to check minimum order amounts before applying a discount.
How do I handle invalid inputs or edge cases fast?+
Check for zero or negative prices, invalid discount percentages or amounts, and expired coupons. Start by writing out three test cases: full discount applied, no discount, and partial discount. That usually exposes your logic gaps in seconds.
Is there a trick to solving this in under 5 minutes?+
Yes. Don't over-engineer it. Write a simple function that reads the price and discount rules, applies them step by step, and returns the result. Don't try to be clever with data structures. Clarity beats optimization here.
Will DoorDash ask follow-up questions if I solve this fast?+
Probably. Expect them to ask how you'd handle multiple discount codes, recurring discounts, or currency conversion. Think about how you'd refactor your code to support those without rewriting everything.