Easy understanding python solution 100% beats solution
Complexity
Time complexity: O(2n)

Space complexity: O(n)
Code
![image.png](https://assets.leetcode.com/users/images/0ac5963b-5910-45c9-a7f6-e39c7b9a4473_1736068374.0846374.png)


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

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

# Code
```python3 []
class Task:
    def __init__(self,userId, taskId, priority):
        self.userId = userId
        self.taskId = taskId
        self.priority = priority
        self.removed = False
    
    def __lt__(self,other):
        if self.priority == other.priority:
            return self.taskId > other.taskId
        
        return self.priority > other.priority

    def __repr__(self):
        return f"({self.userId}, {self.taskId}, {self.priority}, {self.removed})"


class TaskManager:
    def __init__(self, tasks: List[List[int]]):
        tasks_data =[Task(i[0],i[1],i[2]) for i in tasks]
        self.max_heap = [i for i in tasks_data]
        self.register = {i.taskId :i for i in tasks_data}
        heapq.heapify(self.max_heap)
        

    def add(self, userId: int, taskId: int, priority: int) -> None:
        task = Task(userId,taskId,priority)
        heapq.heappush(self.max_heap,task)
        self.register[taskId] = task


    def edit(self, taskId: int, newPriority: int) -> None:
        cur = self.register[taskId]
        self.rmv(taskId)
        self.add(cur.userId,cur.taskId,newPriority)
        

    def rmv(self, taskId: int) -> None:
        task = self.register[taskId]
        task.removed = True
        del self.register[taskId]
        

    def execTop(self) -> int:
        if(len(self.max_heap) > 0):
            task = heapq.heappop(self.max_heap)
            while(task.removed):
                if(len(self.max_heap) <= 0):
                    return -1
                task = heapq.heappop(self.max_heap)
            self.rmv(task.taskId)
            return task.userId
        else:
            return -1
        


# Your TaskManager object will be instantiated and called as such:
# obj = TaskManager(tasks)
# obj.add(userId,taskId,priority)
# obj.edit(taskId,newPriority)
# obj.rmv(taskId)
# param_4 = obj.execTop()
```
['Design', 'Ordered Map', 'Heap (Priority Queue)', 'Ordered Set', 'Python3']