Simple solution. Wrong answer is just one test case. Not able to understand why?
IntuitionRemember taskid is unique so we can have data structures surrounding thatApproachUsing 2 maps and 1 max heap for simplificationComplexity
Time complexi
# Intuition
Remember taskid is unique so we can have data structures surrounding that 

# Approach
Using 2 maps and 1 max heap for simplification 

# Complexity
- Time complexity:
Worst: O(nlogn)


# Code
```cpp []
class TaskManager {
public:
    unordered_map<int,int> tasks_to_user;
    unordered_map<int,int> tasks_to_priority;
    priority_queue<pair<int,int>> max_heap_priority;
    TaskManager(vector<vector<int>>& tasks) {
        for(int i=0;i<tasks.size();i++){
            int userid=tasks[i][0];
            int taskid=tasks[i][1];
            int priority=tasks[i][2];
            tasks_to_user[taskid]=userid;
            tasks_to_priority[taskid]=priority;
            max_heap_priority.push({priority,taskid});
        }
    }
    
    void add(int userId, int taskId, int priority) {
        tasks_to_user[taskId]=userId;
        tasks_to_priority[taskId]=priority;
        max_heap_priority.push({priority,taskId});
    }
    
    void edit(int taskId, int newPriority) {
        tasks_to_priority[taskId]=newPriority;
        max_heap_priority.push({newPriority,taskId});
    }
    
    void rmv(int taskId) {
        tasks_to_priority.erase(taskId);
        tasks_to_user.erase(taskId);
    }
    
    int execTop() {
        while(!max_heap_priority.empty()){
            pair<int,int> p=max_heap_priority.top();
            max_heap_priority.pop();
            if(tasks_to_user.count(p.second)==0) continue; //task has been removed
            if(tasks_to_priority[p.second]!=p.first) continue; //task has been updated
            return tasks_to_user[p.second];
        }
        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();
 */
```

Test case it failed in:

Wrong Answer
662 / 663 testcases passed
submitted at Jan 20, 2025 18:55
(a very very very long test case)
Can someone please help whats wrong?
['Hash Table', 'Design', 'Heap (Priority Queue)', 'C++']