yelp
IntuitionApproachComplexity
Time complexity:

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

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

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

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

# Code
```java []
class TaskManager {
    Map<Integer, Integer[]> taskManagerMap;
    PriorityQueue<int[]> maxHeap ;

    public TaskManager(List<List<Integer>> tasks) {
        taskManagerMap = new HashMap<>();
        maxHeap = new PriorityQueue<>((a,b) -> a[0] != b[0] ? b[0] - a[0] : b[1]-a[1]) ;
        for(List<Integer> list : tasks){
            taskManagerMap.put(list.get(1), new Integer[] {list.get(0), list.get(2)}); 
            maxHeap.add(new int[] {list.get(2), list.get(1)});  
        }
    }
    

    public void add(int userId, int taskId, int priority) {
        taskManagerMap.put(taskId, new Integer[] {userId, priority});
        maxHeap.add(new int[] {priority, taskId});  
    }

    public void edit(int taskId, int newPriority) {
        Integer arr[] = taskManagerMap.get(taskId);
        arr[1] = newPriority ;
        taskManagerMap.put(taskId, arr);
        maxHeap.add(new int[] {newPriority, taskId});  
    }

    public void rmv(int taskId) {
        taskManagerMap.remove(taskId);
    }

    public int execTop() {
        while(maxHeap.size()>0){
            int heapArr[] = maxHeap.poll();
            if(taskManagerMap.containsKey(heapArr[1])){ 
                Integer mapArray[] = taskManagerMap.get(heapArr[1]); 
                if(mapArray[1] == heapArr[0]){ 
                    taskManagerMap.remove(heapArr[1]); 
                    return mapArray[0];
                    
                }
            }
        }
        return -1;
    }
}


 
```
['Java']