java simple map and priorityqueue 100% beats
IntuitionUse a map to do the update and a priorityqueue for orderApproachDon't remove element with priorityqueue, which will be O(n) complexity and fail the tes
# Intuition
Use a map to do the update and a priorityqueue for order

# Approach
Don't remove element with priorityqueue, which will be O(n) complexity and fail the test. Mark it as removed by setting userId =-1, and check it in the execTop() method. 

# Complexity
- Time complexity:
O(log(n))

- Space complexity:
0(n)

# Code
```java []
class TaskManager {
    // int[] a =[priority, taxId, userId]
    Map<Integer, int[]> map = new HashMap<>();
    PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> a[0] != b[0] ? b[0] - a[0] : b[1] - a[1]);

    public TaskManager(List<List<Integer>> tasks) {
        for (int i = 0; i < tasks.size(); i++) {
            int[] a = new int[] { tasks.get(i).get(2), tasks.get(i).get(1), tasks.get(i).get(0) };
            map.put(a[1], a);
            pq.add(a);
        }
    }

    public void add(int userId, int taskId, int priority) {
        int[] a = new int[] { priority, taskId, userId };
        map.put(taskId, a);
        pq.add(a);
    }

    public void edit(int taskId, int newPriority) {
        int[] a = map.get(taskId);
        if (a != null) {
            int[] b = new int[] { newPriority, a[1], a[2] };
            a[2] = -1;
            pq.add(b);
            map.put(taskId, b);
        }
    }

    public void rmv(int taskId) {
        int[] a = map.get(taskId);
        if (a != null) {
            a[2] = -1;
            map.remove(taskId);
        }
    }

    public int execTop() {
        while (!pq.isEmpty()) {
            int[] a = pq.poll();
            if (a[2] != -1) {
                map.remove(a[1]);
                return a[2];
            }
        }
        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();
 */
```
['Java']