Minimum Number of Work Sessions to Finish the Tasks
A medium-tier problem at 34% community acceptance, tagged with Array, Dynamic Programming, Backtracking. Reported in interviews at Swiggy and 0 others.
You've got a pile of tasks with deadlines and session limits. You need to figure out the minimum number of work sessions to finish them all. This problem hits the intersection of constraint satisfaction and state space search, which is why Swiggy and others ask it. The acceptance rate sits at 34%, which means most candidates either brute-force it inefficiently or miss the bitmask optimization entirely. If you haven't practiced bitmask DP with backtracking, you'll likely blank on the live assessment. StealthCoder surfaces a working solution in seconds if you hit this problem during your OA.
Companies that ask "Minimum Number of Work Sessions to Finish the Tasks"
Minimum Number of Work Sessions to Finish the Tasks 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. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderThe trick is to recognize this as a state-search problem where each state represents a subset of completed tasks. You use a bitmask to encode which tasks are done, then backtrack through possible session allocations to find the minimum number of sessions needed. The naive greedy approach fails because task scheduling is order-dependent within session windows. Many candidates try pure DP without backtracking and get stuck. The real insight: combine bitmask representation with recursive backtracking to prune impossible branches early. You explore assigning tasks to new sessions and reusing partial sessions, tracking the minimum result. Common pitfall: not memoizing based on both the bitmask state and the current session's remaining time. If the session cap is small and task count is under 15-20, bitmask backtracking becomes tractable. StealthCoder handles this when the greedy intuition fails and you're out of time.
Pattern tags
You know the problem.
Make sure you actually pass it.
Minimum Number of Work Sessions to Finish the Tasks 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. Built by an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Number of Work Sessions to Finish the Tasks interview FAQ
Is this really a medium, or is 34% acceptance just brutal grading?+
It's legitimately medium difficulty, but the 34% rate reflects that most candidates don't recognize bitmask DP on sight. The algorithm itself is sound once you see it, but the setup and memoization logic trip people up under time pressure.
Do I need to know bitmask DP to solve this, or is there a greedy way?+
Greedy fails here because you can't always fill sessions optimally in a single pass. The bitmask approach forces you to explore all valid task-to-session assignments. Without it, you'll TLE on larger inputs or time out on the live OA.
What's the biggest trap candidates fall into?+
Forgetting to track remaining time in the current session during backtracking. You need to know not just which tasks are done, but how much capacity is left in the current session, or you'll overcount sessions.
How does backtracking fit with DP here?+
Backtracking explores the tree of session assignments. DP (memoization) prunes branches by caching results for each bitmask state. Together, they avoid recalculating the same task subsets.
Does Swiggy really ask this, and how often?+
Yes, Swiggy has reported asking it. With only one company in the data, frequency is limited, but the problem structure is common in backend scheduling and resource allocation roles.
Want the actual problem statement? View "Minimum Number of Work Sessions to Finish the Tasks" on LeetCode →