Very Very Easy Solution || Very easy Explanation || 100% beats || C++
IntuitionMu intuition is basiclaly
we need to track the higest elemnet
SO i will use Heap
and we need to store the details also SO I will use map for the sameAp
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Mu intuition is basiclaly 
we need to track the higest elemnet 
SO i will use Heap 
and we need to store the details also SO I will use map for the same 

# Approach
<!-- Describe your approach to solving the problem. -->
So we have three fucntion 
`TaskManager` : this one simple in which we just need to iterate over tasks and enter in the map and maxHeap

`add` : This is also siimple we just need to add the data in heap and map

`edit` : the same as add we just need to edit data in our map and add the new priority in heap(why we are doing this I will let you know in execTop() function)

`rmv` : Its also very simple just removeing the taskId from the map

`execTop()` : this is the amin function where we will implwmwnt the logic 
So here first of all we are checking in 
`clearHeap() ` :  so what this fucntion is basically doing is removing the unwanted element from the heap 
and we are checking this by just checking the top element priority with the task id in our map if its dont matched then it means that the maxHeap top element need to be remove and we are doing it iteratively 
else we are breaking 
and returning the userId 
Thats Simple !!

Hoope this is easy understnding 
Thanks 
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
$$O(n)$$

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

# Code
```cpp []
class TaskManager {
public:
    unordered_map<int,pair<int,int>> mp;
    priority_queue<pair<int,int>> pq;
    unordered_map<int,int> toBeRemove; 
    TaskManager(vector<vector<int>>& tasks) {
        for(auto i : tasks){
            int userId=i[0];
            int taskId=i[1];
            int prio=i[2];
            mp[taskId]={prio,userId};
            pq.push({prio,taskId});
        }
    }

    void clearHeap() {
        while (!pq.empty()) {
// the condtion to check the element is to be removed from the heap or not 
            if(mp.find(pq.top().second)==mp.end() || mp[pq.top().second].first!=pq.top().first){
                pq.pop();
            }
            else break;
        }
    }
    
    void add(int userId, int taskId, int priority) {
        pq.push({priority,taskId});
        mp[taskId]={priority,userId};
    }
    
    void edit(int taskId, int newPriority) {
        pq.push({newPriority,taskId});
        mp[taskId].first=newPriority;
    }
    
    void rmv(int taskId) {
        mp.erase(taskId);
    }

void print(priority_queue<pair<int,int>> pq){
            while(!pq.empty()){
            cout<<pq.top().first<<" "<<pq.top().second<<"\n";
            pq.pop();
        }
}
    
    int execTop() {
        // print(pq);
        clearHeap();
        if(pq.empty()) return -1;
        auto [prio,taskId]=pq.top();
        pq.pop();
        int ans=mp[taskId].second;
        mp.erase(taskId);
        return ans;
    }
};

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