Go Back
Anthropic Online Assessment -- Task Management System
Anthropic
Software Engineer
Problem Description
Requirements
Level 1
Implement a simple task management system that handles tasks with CRUD operations.
- addTask(taskId: String, priority: Int) -> Boolean: Adds a task. Returns false if the taskId already exists; otherwise, returns true.
- updateTask(taskId: String, newPriority: Int) -> Boolean: Updates the priority of an existing task. Returns false if the task is not found.
- getTask(taskId: String) -> Task | null: Returns the task details.
Example: image slide 1.
Level 2
Implement Search and Sorting functions based on task priority.
- searchTasks(minP: Int, maxP: Int) -> List: Returns a list of taskIds where minP <= priority <= maxP.
- Sorting Requirement: Results must be sorted by priority (descending).
- Tie-breaking: If priorities are equal, sort by creation order (descending)—meaning the task added most recently appears first.
Example: image slide 2.
Level 3
Introduce user ownership, time-sensitive expiration, and resource limits.
- addUser(userId: String, quota: Int) -> Boolean: Registers a user with a maximum number of active tasks. Returns false if the userId already exists.
- assignTask(taskId: String, userId: String, priority: Int, ttl: Int, timestamp: Int) -> Boolean:
- Checks if the user exists and has not exceeded their quota.
- Calculates expiration: Task expires at timestamp + ttl.
- Returns false if the user is at quota, the user doesn't exist, or the taskId already exists.
Note: Before processing, the system must expire any tasks whose timestamp + ttl <= current_timestamp.
Example: image slide 3.
Level 4
Track the lifecycle of tasks to differentiate between successful completion and expiration.
- completeTask(taskId: String, finishTime: Int) -> Boolean: Marks a task as "Completed." Returns false if the task does not exist, has already expired (based on finishTime), or was already completed. If successful, the user’s active task - count decreases, freeing up quota.
- getOverdueTasks() -> List: Returns a list of taskIds that transitioned to an "Expired" state without being completed.
Example: image slide 4.

Hints
No hints available for this question.