Beats 100% | Priority Queue + Maps
IntuitionRemember and Push  into data strucutureApproachThese type of problems neeed peek value in O(1),insert in o(logn), delete in O(1) only edit we some need
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Remember and Push  into data strucuture 
# Approach
<!-- Describe your approach to solving the problem. -->
These type of problems neeed peek value in O(1),insert in o(logn), delete in O(1) only edit we some need to manage in o(logn) .
This can be acheived in remember the elements against id using maps
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
o(n*logn)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class TaskManager {
public:
    using pii = pair<int,int>;
    priority_queue<pii> pq;
   
    unordered_map<int,int> tu;
    unordered_map<int,int> tp;
    unordered_set<int> tid;
    TaskManager(vector<vector<int>>& t) {
        for(auto i:t){
            // [userId, taskId, priority]
            pq.push({i[2],i[1]});
            tu[i[1]]=i[0];
            tp[i[1]]=i[2];
            tid.insert(i[1]);
        }
    }
    
    void add(int u, int t, int p) {
        pq.push({p,t});
        tu[t]=u;
        tp[t]=p;
        tid.insert(t);
    }
    
    void edit(int t, int p) {
        tp[t]=p;
        pq.push({p,t});
        
    }
    
    void rmv(int t) {
        tid.erase(t);
    }
    
    int execTop() {
       
        while(pq.size()){
            auto [p,t] = pq.top();
             if(tid.find(t)!=tid.end()){
                if(tp[t]==p) {
                    pq.pop();
                    tid.erase(t);
                    return tu[t];
                }
            }
            pq.pop();
        }
        return -1;
    }
};

/**
 * 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++']