Reported July 2026
Appleheap priority queue

Design Task Manager

Reported by candidates from Apple's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Apple OA. Under 2s to a working solution.
Founder's read

Apple's July 2026 OA reports include a task manager where EXEC_TOP has to pop the highest priority task, and ties go to the larger taskId. That tie rule is the detail that trips people. It's a priority queue problem wearing a design-class costume, with ADD, EDIT, RMV and EXEC_TOP all hitting the same structure. Up to 2*10^5 operations means a naive scan per execute will die. If you blank on the data structure choice during the live assessment, StealthCoder sits invisibly on your screen and hands you a working approach. Here's the pattern before you need it.

The problem

Manage tasks owned by users. Every task has a unique integer taskId, an integer userId, and an integer priority. The initial array tasks contains rows [userId, taskId, priority].
For this exercise, process the finite batch operations. Each row is one of:
["ADD", userId, taskId, priority]: add a task. The supplied taskId is not currently present.
["EDIT", taskId, newPriority]: change the priority of an existing task.
["RMV", taskId]: remove an existing task.
["EXEC_TOP"]: execute and remove the task with the greatest priority. If several tasks have that priority, execute the one with the greatest taskId. Return its userId, or -1 when no task is available.
The numeric fields in operations are decimal strings. Return the result of every EXEC_TOP operation in order.

Function
runTaskManager(tasks: int[][], operations: String[][]) → int[]

Examples
Example 1
tasks = [[1,101,10],[2,102,20],[3,103,15]]
operations = [["ADD","4","104","5"],["EDIT","102","8"],["EXEC_TOP"],["RMV","101"],["ADD","5","105","15"],["EXEC_TOP"]]
return = [3,5]
After task 102 is lowered to priority 8, task 103 is the first task executed, so the first result is user 3. Task 101 is removed, and newly added task 105 is then the highest-priority task, so the second result is user 5.
Example 2
tasks = [[1,10,5],[2,20,5]]
operations = [["EXEC_TOP"],["EDIT","10","7"],["EXEC_TOP"],["EXEC_TOP"]]
return = [2,1,-1]
The initial priority tie is broken by the larger task ID, so task 20 returns user 2. Editing task 10 makes it the next result. The final execution finds no task and returns -1.

Constraints
1 <= tasks.length <= 10^5
Every initial row is [userId, taskId, priority], and initial task IDs are unique.
0 <= userId, taskId <= 10^5
0 <= priority, newPriority <= 10^9
0 <= operations.length <= 2 * 10^5
Every operation has a valid name and arity.
An ADD task ID is absent when added; an EDIT or RMV task ID is present when used.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a max-heap keyed on (priority, taskId) plus lazy deletion. Keep a hash map from taskId to its current (userId, priority). On ADD, put it in the map and push to the heap. On EDIT, update the map and push a fresh heap entry. On RMV, just delete from the map. On EXEC_TOP, pop until the top entry matches the map's current priority for that taskId, then remove it and return its userId. If the heap empties, return -1. The common pitfall is forgetting stale entries after EDIT, so an old high priority executes a task that was lowered. Another is the tiebreak direction: larger taskId wins. Also remember the operation fields arrive as strings, so parse them. Total cost is O(n log n). StealthCoder is the hedge if you freeze on lazy deletion during the live OA.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Design Task Manager 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 StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Apple's OA.

Apple 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.

Design Task Manager FAQ

What's the trick in the Apple Design Task Manager OA?+

Use a max-heap ordered by priority, then taskId, plus a hash map of live tasks. Don't try to update heap entries in place. Push a new entry on EDIT and skip stale ones when you pop. That's lazy deletion, and it keeps everything logarithmic.

How do I detect a stale heap entry?+

When you pop, look up the taskId in the map. If it's missing, the task was removed or already executed. If the map's priority differs from the popped priority, it was edited. Either way, discard and pop again. Only a match is valid to execute.

How hard is this problem really?+

Medium. The logic is simple once you know lazy deletion. The difficulty is design discipline with four operations and a tiebreak rule. With 2*10^5 operations, brute force scans time out, so the heap approach is required rather than optional.

What edge cases should I test?+

Calling EXEC_TOP on an empty manager returns -1. Test equal priorities where the larger taskId must win, as in Example 2. Test editing a task then removing it, and re-adding a removed taskId. Also check priorities up to 10^9 and string parsing of every numeric field.

How do I prepare in 48 hours?+

Write a heap with lazy deletion from scratch twice, in your language of choice. Know how to get max-heap behavior with tuple ordering or negated keys. Then run both examples by hand. Similar design problems on top-k and schedulers use the same skeleton.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Apple.

OA at Apple?
Invisible during screen share
Get it