Simple Design | Map & Set
Complexity
Time complexity:
O(n log n)
Space complexity:
O(n)Code

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(n log n)
---
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(n)
---
# Code
```cpp []
class TaskManager {
public:
    multiset<pair<int, pair<int, int>>>st, temp;
    unordered_map<int, pair<int, int>>mp;
    TaskManager(vector<vector<int>>& tasks) {
        for(auto it: tasks){
            add(it[0], it[1], it[2]);
        }
    }
    
    void add(int userId, int taskId, int priority) {
        st.insert({priority, {taskId, userId}});
        mp[taskId] = {userId, priority};
    }
    
    void edit(int taskId, int newPriority) {
        rmv(taskId);
        add(mp[taskId].first, taskId, newPriority);
    }
    
    void rmv(int taskId) {
        st.erase({mp[taskId].second, {taskId, mp[taskId].first}});
    }
    
    int execTop() {
        if(!st.size()) return -1;
        auto it = *st.rbegin();
        rmv(it.second.first);
        return it.second.second;
    }
};
```
['Hash Table', 'Design', 'Recursion', 'Heap (Priority Queue)', 'Ordered Set', 'C++']