C++ multi mapping and set
ApproachTaskId is to be mapped with UserID and priority. Rest is simple execution as in the code.Complexity
Time complexity: O(NlogN)

Space complexity: O(NlogN

# Approach
TaskId is to be mapped with UserID and priority. Rest is simple execution as in the code.
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity: O(NlogN)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(NlogN)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class TaskManager {
    unordered_map<int, int> taskToUserID;
    unordered_map<int, int> taskPriority;
    set<pair<int, int>> set;
public:
    TaskManager(vector<vector<int>>& tasks) {
        for(auto it: tasks) {
            taskToUserID[it[1]]= it[0];
            taskPriority[it[1]]= it[2];
            set.insert({it[2], it[1]});
        }
    }
    
    void add(int userId, int taskId, int priority) {
        taskToUserID[taskId]= userId;
        taskPriority[taskId]= priority;
        set.insert({priority, taskId});
    }
    
    void edit(int taskId, int newPriority) {
        int oldPriority= taskPriority[taskId];
        taskPriority[taskId]= newPriority;
        set.erase({oldPriority, taskId});
        set.insert({newPriority, taskId});
    }
    
    void rmv(int taskId) {
        // int userId= taskToUserId[taskId];
        int priority= taskPriority[taskId];
        set.erase({priority, taskId});
        taskToUserID.erase(taskId);
        taskPriority.erase(taskId);
    }
    
    int execTop() {
        if(set.empty()) return -1;
        int taskId= set.rbegin()->second;
        int priority= set.rbegin()->first;
        set.erase({priority, taskId});
        return taskToUserID[taskId];
    }
};

/**
 * Your TaskManager object will be instantiated and called as such:
 * TaskManager* obj = new TaskManager(tasks);
 * obj->add(userId,taskId,priority);
 * obj->edit(taskId,newPriority);
 * obj->rmv(taskId);
 * int param_4 = obj->execTop();
 */
```
['C++']