Maximum Number of Weeks for Which You Can Work
A medium-tier problem at 41% community acceptance, tagged with Array, Greedy. Reported in interviews at Wells Fargo and 1 others.
You're given an array of project deadlines and you need to figure out the maximum number of weeks you can actually work without missing one. Wells Fargo and SAP have both asked this. It sounds straightforward until you realize the greedy trap: picking the longest project first doesn't guarantee you'll finish everything on time. The trick is recognizing when a single project dominates so hard that it blocks you no matter what order you choose. This is a medium-difficulty greedy problem that catches a lot of candidates because the optimal insight isn't obvious. If you hit this live and freeze, StealthCoder surfaces the working pattern in seconds, invisible to the proctor.
Companies that ask "Maximum Number of Weeks for Which You Can Work"
Maximum Number of Weeks for Which You Can Work is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made for the engineer who has done the work but might still blank with a webcam pointed at him.
Get StealthCoderThe problem boils down to understanding when you can schedule all projects versus when one project's deadline is so tight it becomes a bottleneck. The greedy insight is that you should alternate between your longest and second-longest remaining projects to stay ahead of deadlines. But here's where most candidates derail: they don't recognize the critical condition where the longest project alone exceeds the total time available. If one project's deadline is smaller than that project's duration plus all other durations combined, you're blocked and can't finish everything. The algorithm requires sorting by duration, then checking this boundary condition before greedily pairing projects. Common mistakes include ignoring the dominance check or trying to schedule sequentially instead of interleaving. When this appears in your online assessment, having the greedy pairing pattern and the blocking condition ready means you don't waste 20 minutes on a wrong approach.
Pattern tags
You know the problem.
Make sure you actually pass it.
Maximum Number of Weeks for Which You Can Work recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made for the engineer who has done the work but might still blank with a webcam pointed at him. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Number of Weeks for Which You Can Work interview FAQ
How hard is this problem really compared to other greedy problems?+
It's medium difficulty because the greedy strategy itself is straightforward once you see it, but recognizing the bottleneck condition requires thinking about what blocks you. Most candidates solve the scheduling part but miss the edge case where one project makes the whole plan impossible.
Is this still asked at FAANG-adjacent companies?+
Wells Fargo and SAP have both asked it, so yes. It's not as common as array or string problems, but it appears regularly in technical screens. If your recruiter mentioned greedy algorithms, this is a reasonable prep target.
What's the core trick that makes this greedy problem different?+
Most greedy problems ask you to optimize incrementally. This one adds a constraint: you must also detect when optimization is impossible. The trick is the upfront check that determines whether all projects fit or not, then the pairing logic only applies if they do.
How does this relate to scheduling and interval problems?+
It shares the scheduling flavor of interval problems but skips traditional interval merging. Instead, it uses greedy pairing and a feasibility check. If you're strong on sorting and deadline reasoning, you have half the mental model already.
What's the most common wrong turn candidates take?+
Trying to greedily assign projects in sorted order without checking if the longest project's deadline is the actual bottleneck first. Others simulate the scheduling process instead of doing the math upfront. Both waste time on an assessment when the pattern is just two key insights.
Want the actual problem statement? View "Maximum Number of Weeks for Which You Can Work" on LeetCode →