Maximize Secondary Tasks Scheduled
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon's October OA threw a scheduling problem at candidates with minimal context. You're given constraints on primary and secondary tasks, and you need to maximize how many secondary tasks fit. It's a greedy or dynamic-programming play depending on the input structure. If you blank on the approach during the live OA, StealthCoder reads the problem in real time and surfaces the right strategy so you're not guessing under pressure.
Pattern and pitfall
The core trick: recognize whether this is a pure greedy sort (tasks by duration or deadline, then pack as many secondary tasks as possible) or whether you need DP to track state across time slots. Most candidates overthink it as DP when the solution is greedy sort plus a linear scan. The pitfall is not clarifying what 'secondary' means in the context of your schedule. Are primary tasks fixed, or do you choose them first. If you can't reconstruct the exact constraints during the OA, StealthCoder is your safety net to feed you the solution pattern instantly so you move forward.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Maximize Secondary Tasks Scheduled 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 by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximize Secondary Tasks Scheduled FAQ
Is this a DP problem or greedy?+
If primary tasks are fixed and you're packing secondary tasks into free slots, it's usually greedy (sort secondary tasks by duration or deadline, then fill slots). If you're choosing which primary tasks to do first, it's DP or a more complex search. The problem statement will tell you.
What's the common mistake on this one?+
Not reading whether primary tasks have flexible timing. If they're locked to specific time windows, you can't move them. That changes everything. Also, candidates often forget to handle overlaps or assume secondary tasks are all unit length.
How long does this usually take to code?+
If it's greedy, 10-15 minutes once you're sure of the approach. If it's DP, 20-30 minutes. The first 5 minutes is usually spent re-reading the problem to confirm what's fixed and what's variable.
Is this harder than typical Amazon OA problems?+
Not harder, just under-specified in the problem statement. Amazon loves scheduling and bin-packing variants. The real challenge is inferring the exact constraint model from vague language. Clarify assumptions early.
What should I code first, greedy or DP?+
Code greedy first. Sort secondary tasks, iterate through time, pack them. If it fails test cases, pivot to DP with memoization on remaining time and remaining tasks. Greedy passes more often than candidates expect.