286 ms using PriorityQueue and HashMap !!! Understanable solution (Updated)
IntuitionApproachComplexity
Time complexity:  O(nlogn)

Space complexity:  O(n)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:  $$O(nlogn)$$
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```java []
class TaskManager {
    Queue<Task> pq = new PriorityQueue<>(new Comparator<Task>() {

        @Override
        public int compare(Task t1, Task t2) {
            if(t1.p != t2.p) {
                return t2.p - t1.p;
            }else if(t1.id != t2.id){
                return t2.id - t1.id;
            }else{
                return t2.u - t1.u;
            }
        }
    });
    Map<Integer, Pair> hm = new HashMap<>();
    public TaskManager(List<List<Integer>> tasks) {
        for(List<Integer> t : tasks){
            pq.add(new Task(t.get(0), t.get(1), t.get(2)));
            hm.put(t.get(1), new Pair(t.get(0), t.get(2)));
        }
    }
    
    public void add(int userId, int taskId, int priority) {
        pq.add(new Task(userId, taskId, priority));
        hm.put(taskId, new Pair(userId, priority));
    }
    
    public void edit(int taskId, int newPriority) {
        /*Pair p = hm.get(taskId);
        Task ts = new Task(p.u, taskId, p.p);
        
        pq.remove(ts);
        pq.add(new Task(ts.u, taskId, newPriority));
        hm.put(taskId, new Pair(p.u, newPriority));*/
        if (hm.containsKey(taskId)) {
            Pair p = hm.get(taskId);
            hm.put(taskId, new Pair(p.u, newPriority)); // Update task in the map
            pq.add(new Task(p.u, taskId, newPriority)); // Add updated task to the queue
        }
        
    }
    
    public void rmv(int taskId) {
        //Pair p = hm.get(taskId);
        //Task ts = new Task(p.u, taskId, p.p);
        //pq.remove(ts); dont do this , o(n) tc
        hm.remove(taskId);
    }
    
    public int execTop() {
       while (!pq.isEmpty()) {
            Task top = pq.poll(); // logn
            if (hm.containsKey(top.id) && hm.get(top.id).p == top.p) {
                hm.remove(top.id); // Remove the executed task from the map
                return top.u;
            }
        }
        return -1; 
    }
}

class Pair{
    int u, p;
    Pair(int u, int p){
        this.u= u;
        this.p = p;
    }
}

class Task{
    int u, id, p;
    Task(int u, int id, int p){
        this.u = u;
        this.id = id;
        this.p = p;
    }

    @Override
    public boolean equals(Object o){
        return this.id == ((Task)o).id;
    }

    @Override
    public int hashCode() {
        return u;
    }
    
}

/**
 * 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)', 'Java']