← Questions
Task manager with TTL expiry and time-travel snapshots
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A four-level task manager: per-user task lists first, then TTL-based auto-deletion, then a snapshot read that returns a user's tasks as they stood at any past timestamp.
-
Level 1:
add_task(ts, user, name, priority)returns"task1", ...;get_task,update_task,delete_task. -
Level 2:
list_tasks(ts, user): live task names, highest priority first, ties in creation order. -
Level 3:
add_task_with_ttl(ts, user, name, priority, ttl): alive forts <= t < ts + ttl. -
Level 4:
tasks_at(ts, user, at): whatlist_taskswould have returned at the past timeat.
class TaskManager:
def add_task(self, ts, user, name, priority): ...
def get_task(self, ts, task_id): ...
def update_task(self, ts, task_id, name, priority): ...
def delete_task(self, ts, task_id): ...
def list_tasks(self, ts, user): ...
def add_task_with_ttl(self, ts, user, name, priority, ttl): ...
def tasks_at(self, ts, user, at): ...
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.
Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding
