Skip to content

Practice Design Task Manager

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#3408
LeetCode Problem

Design Task Manager

Problem Statement

Implement TaskManager for tasks identified by taskId and assigned to users with priorities. The constructor TaskManager(tasks) loads triples [userId, taskId, priority]. add(userId, taskId, priority) adds a previously absent taskId. edit(taskId, newPriority) changes an existing task’s priority, and rmv(taskId) deletes an existing task. execTop() removes the task with greatest priority across all users, breaking ties by greatest taskId, and returns its userId; return -1 when no tasks remain. A user can own multiple tasks.

Source: Design Task Manager on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
["TaskManager", "add", "edit", "execTop", "rmv", "add", "execTop"] [[[[1, 101, 10], [2, 102, 20], [3, 103, 15]]], [4, 104, 5], [102, 8], [], [101], [5, 105, 15], []]
Output
[null, null, null, 3, null, null, 5]

Constraints

1 <= tasks.length <= 10^5
0 <= userId <= 10^5
0 <= taskId <= 10^5
0 <= priority <= 10^9
0 <= newPriority <= 10^9
At most 2 * 10^5 calls will be made in total to add, edit, rmv, and execTop methods.
The input is generated such that taskId will be valid.

Related LeetCode Problems

Practice more problems similar to Design Task Manager.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.