Kotlin - soft delete, beats 100%
Approachdelete = "soft delete": just set active = false
edit = soft delete + add (smth like MVCC)
exec = poll and skip deletedComplexity

Time complexity:
O(N)
# Approach
delete = "soft delete": just set active = false
edit = soft delete + add (smth like MVCC)
exec = poll and skip deleted

# Complexity
- Time complexity:
O(N)

- Space complexity:
O(N)

# Code
```kotlin []
class TaskManager(tasks: List<List<Int>>) {
    private data class Task(
        val userId: Int,
        val taskId: Int,
        var priority: Int,
    ) {
        var active = true
    }
    private val pq = PriorityQueue(
        compareByDescending<Task> { it.priority }.thenByDescending { it.taskId }
    )
    private val idToTask = mutableMapOf<Int, Task>()

    init {
        tasks.forEach { (userId, taskId, priority) ->
            add(userId, taskId, priority)
        }
    }

    fun add(userId: Int, taskId: Int, priority: Int) {
        val task = Task(userId, taskId, priority)
        pq.add(task)
        idToTask[taskId] = task
    }

    fun edit(taskId: Int, newPriority: Int) {
        val task = idToTask.getValue(taskId)
        rmv(taskId)
        add(task.userId, taskId, newPriority)
    }

    fun rmv(taskId: Int) {
        idToTask[taskId]?.active = false
        idToTask.remove(taskId)
    }

    fun execTop(): Int {
        while (true) {
            val task = pq.poll() ?: return -1
            if (task.active) return task.userId
        }
    }
}

```
['Kotlin']