Timed Task Management
Reported by candidates from Instacart's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Instacart's September 2026 OA hands you a task manager with six operations, and the trap is hiding in the last one. ADD, FILTER, RANGE, RUN and FINISHED are bookkeeping with a shared sort order. CAN_FINISH is where a naive solution quietly returns the wrong answer. Each task needs its own distinct integer slot inside the overlap of its window and the query range. If you've got an OA invite and under three days, read this closely. The pattern is a queue-style scheduler plus an interval feasibility check. StealthCoder sits invisibly on your screen as a safety net if you blank on the slot assignment during the live OA.
The problem
Implement a finite task-management operation stream. Each task has a unique string ID, integer creation time, inclusive start time, exclusive end time, integer priority, and completion state. A task takes one integer time unit to run. ["ADD", id, created, start, end, priority]: add the task and return "true", or "false" for a duplicate ID. ["FILTER", field, value]: list unfinished tasks whose CREATED, START, END, or PRIORITY field equals value. ["RANGE", left, right]: list unfinished tasks whose start time is in [left,right). ["RUN", timestamp]: complete one unfinished task with start <= timestamp < end. Choose greatest priority, then earliest creation time, then lexicographically smallest ID. Return its ID or NONE. ["FINISHED", id]: return whether the task exists and is finished. ["CAN_FINISH", left, right]: without mutating state, return whether every unfinished task whose window intersects [left,right) can receive a distinct integer unit slot within the intersection of its own window and that range. FILTER and RANGE use the same priority, creation-time, and ID ordering and join IDs with commas. Function manageTimedTasks(operations: String[][]) → String[] Examples Example 1 operations = [["ADD","a","0","1","4","3"],["ADD","b","1","1","3","5"],["FILTER","PRIORITY","5"],["RUN","1"],["FINISHED","b"],["CAN_FINISH","1","4"]] return = ["true","true","b","b","true","true"] b has greater priority and runs first. The remaining unit task a fits before time 4. Example 2 operations = [["ADD","a","0","0","1","1"],["ADD","b","0","0","1","2"],["RANGE","0","2"],["CAN_FINISH","0","1"],["RUN","2"]] return = ["true","true","b,a","false","NONE"] Both tasks require the only slot [0,1), so they cannot both finish. Neither is eligible at time 2. Constraints 1 <= operations.length <= 5000. IDs are nonempty and contain no commas. 0 <= created <= start < end <= 10^9. At most 500 unfinished tasks participate in one CAN_FINISH query.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Store tasks in a map by ID. For RUN, FILTER and RANGE, scan and sort by priority descending, creation ascending, ID ascending. With 5000 operations that's fine. The real edge case is CAN_FINISH. Each unfinished task that intersects [left,right) gets a clipped window [max(start,left), min(end,right)). Every task needs a distinct integer slot in its clipped window. Classic greedy: sort clipped windows by start, sweep time with a min-heap keyed on end, and at each slot assign the task with the earliest deadline. If any task's deadline passes unassigned, return false. Jump the clock forward when the heap is empty, because times go up to 10^9. Pitfalls: end is exclusive, so the last valid slot is end-1. Skip empty clipped windows. Don't mutate state. Example 2 shows two tasks fighting for slot 0. If the heap logic slips mid-assessment, StealthCoder is your hedge.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Timed Task Management 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
You've seen the question.
Make sure you actually pass Instacart's OA.
Instacart 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.
Timed Task Management FAQ
What's the trick in the Instacart timed task management OA?+
CAN_FINISH is the trick. Clip each unfinished task's window to the query range, then run earliest-deadline-first with a min-heap over integer slots. If any task misses its deadline, return false. Everything else is a map plus a consistent sort order.
How hard is this problem really?+
Medium on paper, but it's long. Five operations are easy bookkeeping. The difficulty is the slot-assignment feasibility check and handling exclusive ends. Expect most of your time to go into CAN_FINISH and edge cases, not the parsing.
Do I need a priority queue for RUN and FILTER?+
No. With at most 5000 operations, scanning the map and sorting by priority descending, then creation time, then ID is fast enough. Save the heap for CAN_FINISH, where it drives the earliest-deadline-first sweep.
What edge cases break a naive solution?+
Exclusive end times, empty clipped windows, and large timestamps up to 10^9. Don't loop over every integer time. Jump the clock to the next task start when the heap is empty. Also make sure CAN_FINISH never changes task state.
How do I prepare in 48 hours?+
Practice the interval scheduling with deadlines pattern: sort by start, heap by end, sweep. Then write the shared comparator once and reuse it for RUN, FILTER and RANGE. Test with both examples, especially the two-tasks-one-slot case.