Get Discounted Price
Reported by candidates from Oracle's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Oracle's "Get Discounted Price" question hit your inbox in February, and it's a straightforward but easy-to-misread input/output problem. You'll need to parse what's being asked, then apply a discount formula correctly. The trick isn't the algorithm, it's reading the problem statement carefully and handling edge cases like zero discounts or negative prices. StealthCoder will catch you if you misinterpret the input format during the live OA.
Pattern and pitfall
This is a simulation problem dressed as math. You're given prices and discount rates, and you need to output the discounted price for each. The catch is usually in the rounding, the discount application order, or how the input is structured. Most candidates rush and apply the discount backwards, or they round when they shouldn't. The pattern is straightforward: read input, loop through prices, apply discount formula, output result. If you blank on the exact formula or rounding rules during the OA, StealthCoder will pull the problem text and show you the correct output format so you don't lose points on a simple mistake.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Get Discounted 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Oracle's OA.
Oracle reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Get Discounted Price FAQ
What rounding rule does Oracle use for discounted prices?+
Oracle doesn't specify in most versions. Assume no rounding unless the problem explicitly says to round down, round to nearest integer, or truncate. Code defensively: if you're unsure, try both integer division and float output and see which matches the expected format.
Is the discount applied as a multiplier or a percentage subtraction?+
Almost always percentage subtraction: new_price = original_price * (1 - discount_rate). If the discount is given as a percentage (e.g., 20), convert to decimal (0.20) first. Read the problem statement carefully.
Can the discounted price be negative or zero?+
Unlikely in a real scenario, but the problem won't say. Assume prices stay non-negative. If you get a negative result, the problem likely has a constraint or expects you to cap at zero. Check the examples.
How should I handle multiple items with different discounts?+
Loop through each item and apply its discount independently. Don't try to aggregate discounts or apply them cumulatively unless the problem explicitly says so. One item per line, one discounted price per line out.
Is this problem still asked at Oracle in 2024?+
Yes, this was reported in February 2024. It's a basic warm-up, not a screen-killer. Focus on correctness and input parsing. If you solve it cleanly in under 5 minutes, you're on track.