Schedule Tasks
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon's Schedule Tasks question landed in October 2024 OAs and it's a routing puzzle disguised as a scheduling problem. You've got tasks with dependencies, deadlines, or resource conflicts, and you need to find a valid order or detect when none exists. The trap is overthinking it as a graph problem when a greedy or topological sort approach often works. StealthCoder will catch the pattern in seconds if you blank on the algorithm mid-interview.
Pattern and pitfall
This is a classic topological sort or constraint satisfaction problem. Most candidates start by building a directed graph of task dependencies, then either run DFS to detect cycles or use Kahn's algorithm to produce a valid ordering. The trick is recognizing early whether the problem asks for any valid schedule, the lexicographically smallest one, or whether you need to optimize for time or resource usage. Common pitfall: forgetting to validate that all tasks can actually be scheduled before returning a result. If you see task counts under 1000, a simple DFS with backtracking often beats overthinking. StealthCoder will identify whether you need topological sort or greedy assignment in real time, so you won't waste 10 minutes debating approach.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Schedule Tasks 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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as course schedule. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Schedule Tasks FAQ
Is this definitely topological sort?+
Not always. If tasks have time windows or resource limits, it might be greedy assignment or interval scheduling. Read the constraints carefully. If it's pure dependencies with no cycles, topological sort wins. If there are conflicts or constraints beyond ordering, you may need dynamic programming or a greedy heuristic.
What's the most common wrong answer?+
Building the graph correctly but forgetting to check for cycles or returning an incomplete schedule. Also, candidates often miss that the problem may require a specific order (e.g., lexicographically smallest) not just any valid order. Always re-read the output format.
How much time should I spend on edge cases?+
Two minutes max. Test: empty task list, single task, all tasks dependent on one task, circular dependency. If your algorithm handles those, move on. Amazon doesn't usually hide the trick in weird edge cases here.
Can I use a library function for topological sort?+
Probably yes, but verify first. Most platforms allow imports. If you're unsure, implement Kahn's algorithm yourself. It's 15 lines and safer than guessing what a library function does under the hood.
If I can't solve it in 20 minutes, what's my exit strategy?+
Write a greedy solution that picks any available task next. It won't be optimal but it shows structure and usually passes some test cases. Then if you have time, upgrade to proper topological sort. Partial credit beats a blank screen.