#3408

Design Task Manager

specialist · 890 · lc medium +31 · 49.1% accepted · 488 likes · top 35%

Description

A task management system tracks user tasks, each with a priority. The system supports adding, modifying, executing, and removing tasks.

Implement the TaskManager class:

- TaskManager(vector<vector<int>>& tasks) initializes the manager with a list of [userId, taskId, priority] triples.

- void add(int userId, int taskId, int priority) adds a new task; taskId is guaranteed not to exist yet.

- void edit(int taskId, int newPriority) updates the priority of an existing task.

- void rmv(int taskId) removes an existing task from the system.

- int execTop() executes the highest-priority task; ties are broken by the largest taskId. Removes the task and returns its userId. Returns -1 if no tasks remain.

A user may hold multiple tasks.

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24