Design Task Manager

Medium · Heap & Priority Queue · about 25 minutes

Asked at Apple, Google, Amazon, Bloomberg, Microsoft.

Manage tasks owned by users, each with a priority.

  • TaskManager(tasks): tasks[i] = [userId, taskId, priority] are the initial tasks (task ids are unique).
  • add(userId, taskId, priority) adds a task.
  • edit(taskId, newPriority) changes an existing task's priority.
  • rmv(taskId) removes an existing task.
  • execTop() executes and removes the task with the highest priority (ties: the highest taskId) and returns its

userId, or -1 if there are no tasks.

Related guides