✅ C++ sol. using MAP and HEAP
Code


# Code
```cpp []
class TaskManager {
public:
    priority_queue<pair<int,int>> m ;
    map<int , pair<int,int>> task ;
    TaskManager(vector<vector<int>>& tasks) {
        for(auto t : tasks){
            m.push({t[2] , t[1]});
            task[t[1]] = {t[2] , t[0]};
        }
    }
    
    void add(int userId, int taskId, int priority) {
        m.push({priority , taskId });
        task[taskId] = {priority , userId};
    }
    
    void edit(int taskId, int newPriority) {
        task[taskId].first = newPriority;
        m.push({newPriority , taskId});
    }
    
    void rmv(int taskId) {
        task[taskId].first = -1;
    }
    
    int execTop() {
        if(m.empty()){
            return -1 ;
        }
        int taskId = m.top().second;
        int pri = m.top().first ;
        while(!m.empty() && pri != task[taskId].first ){
            m.pop();
            taskId = m.top().second;
            pri = m.top().first ;
        }

        if(m.empty()){
            return -1 ;
        }
        else{
            int userId = task[m.top().second].second ;
            task[m.top().second].first = -1 ;
            m.pop();
            return userId ;
        }
    }
};

/**
 * 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();
 */
```
['Hash Table', 'Ordered Map', 'Heap (Priority Queue)', 'C++']