Calculate Net Profit
Reported by candidates from JP Morgan's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
JP Morgan's June 2025 OA included a profit calculation problem that looks deceptively simple on paper. You read the prompt, think you know what's being asked, and then realize there's a catch in how costs, revenue, or timing are counted. This is a math problem wrapped in a business narrative. StealthCoder will catch the edge cases you miss under pressure, so you can move to the next question clean.
Pattern and pitfall
Net profit problems hinge on what you add, subtract, and when. The trap is usually one of: treating one-time costs as recurring, forgetting about a hidden fee or deduction, misinterpreting the time period, or mixing up margin versus absolute profit. Read the problem twice. Identify every number. Map inputs to outputs. If the problem gives you cost per unit, quantity, and price per unit, build the formula step by step. Off-by-one errors and sign flips (adding instead of subtracting) kill these fast. StealthCoder keeps you from submitting a solution that fails on the second test case because you misread whether a discount applies to total revenue or per item.
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 Calculate Net Profit 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 JP Morgan's OA.
JP Morgan 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.
Calculate Net Profit FAQ
Is this a coding problem or just arithmetic?+
Both. The math is straightforward, but the implementation matters. You'll likely loop over transactions or items and accumulate profit. The catch is in the logic, not the math itself. Read the constraints and work through a small example by hand first.
What's the most common mistake on profit problems?+
Forgetting a cost bucket or applying a discount/tax to the wrong line item. Re-read the problem and list every cost and every revenue source. If it says 'after discount' or 'before tax', that changes the formula. Test on both the given example and an edge case you invent.
Do I need dynamic programming or recursion?+
No. This is a simulation or straightforward math problem. Iterate, accumulate, return the result. If you're thinking DP, you've over-engineered it. Keep it simple.
How do I prepare in 24 hours?+
Work through 2-3 similar problems on LeetCode or interview sites. Focus on problems tagged 'math' or 'simulation' involving costs and revenue. The pattern is always the same: parse the input, apply the formula, handle edge cases (zero items, negative values, etc).
What if the numbers are huge or the time limit feels tight?+
Check if you need to optimize. Most profit problems are O(n) with a single pass. If you're seeing timeout, you're probably iterating more than once unnecessarily. Also watch for integer overflow if the language requires it.