You are implementing an in-memory Task Management System. All API methods are called with a timestamp representing the logical time when the operation happens.
Assume:
timestamp order
.
Each task has:
task_id
description
priority
(integer), default
0
at creation
Implement four methods (all take timestamp):
createTask(timestamp, task_id, description)
getTask(timestamp, task_id) -> description | null
updateTask(timestamp, task_id, new_description)
deleteTask(timestamp, task_id)
Deleting a task removes it from the system and unassigns it from all users.
Implement:
updateTaskPriority(timestamp, task_id, new_priority)
getSortedPrioritizedTasks(timestamp) -> List[task_id]
getSortedPrioritizedTasks should return all currently existing tasks sorted by:
priority
first
task_id
ascending (or another deterministic rule you state)
Implement:
addUser(timestamp, user_id)
assignTaskToUser(timestamp, user_id, task_id)
unassignTaskToUser(timestamp, user_id, task_id)
scheduleDeletion(timestamp, task_id, delay)
scheduleDeletion schedules the task to be deleted at time timestamp + delay.
Important ordering rule: If one or more deletions are scheduled to occur at time T, then at timestamp T those deletions must be applied before any other operations at the same timestamp T.
Implement:
getUserTaskNumsAt(timestamp, user_id, time_at) -> int
This returns the number of tasks assigned to user_id at logical time time_at (where time_at <= timestamp). The result must reflect all creates/deletes/assigns/unassigns/scheduled-deletes that happened up to time_at, with the same deletion-precedence rule at identical timestamps.