← 返回 ramp 的题目列表OA — Task Management System (4 Levels)
类型:qbank
A CodeSignal four-level OA: a task manager with CRUD + sequential IDs, substring search and priority sorting, time-windowed user assignments under a quota, and completion / overdue tracking.
Requirements
A four-level task-management system. Each level unlocks after all tests pass; efficiency not graded.
Level 1 — CRUD with sequential IDs
add_task(timestamp, name, priority) -> str — adds a task, returns a unique id "task_id_N" (sequential from task_id_1). Same name+priority is allowed; each task gets a distinct id. priority is a non-negative int. timestamp is unused at L1 but kept for API consistency.
update_task(timestamp, task_id, name, priority) -> bool — updates name/priority; returns False if task_id doesn't exist.
get_task(timestamp, task_id) -> str | None — returns the task details (name, priority) as a JSON string, or None.
Level 2 — Search & sort
search_tasks(timestamp, name_filter, max_results) -> list[str] — task ids whose names contain name_filter (case-sensitive substring), up to max_results, sorted by priority desc, then by creation order asc (numeric id sequence, so task_id_2 before task_id_10). max_results <= 0 → empty list.
list_tasks_sorted(timestamp, limit) -> list[str] — up to limit ids, priority desc then creation order asc.
Level 3 — Users, quotas, time-windowed assignment
add_user(timestamp, user_id, quota) -> bool — new user with a max number of simultaneously-active assignments; False if user exists.
assign_task(timestamp, task_id, user_id, finish_time) -> bool — assignment active over [timestamp, finish_time). False if task/user missing or quota reached; each active assignment consumes one quota slot.
get_user_tasks(timestamp, user_id) -> list[str] — active task ids where start_time <= timestamp < finish_time.
Level 4 — Completion & overdue
complete_task(timestamp, task_id, user_id) -> bool — assignment must be active at timestamp; completing it frees the quota slot immediately. False if task/user missing or not assigned to that user at timestamp.
get_overdue_assignments(timestamp, user_id) -> list[str] — ids assigned to the user that expired uncompleted (finish_time <= timestamp and not completed before that assignment's finish_time).
Notes
The numeric creation-order tie-breaker (task_id_2 before task_id_10) is a deliberate trap — sort on the integer sequence, not the string id.
Levels 3–4 hinge on modeling each assignment as an interval with a completion flag; quota is the count of currently-active, uncompleted assignments. Keep per-user assignment lists so get_user_tasks, completion, and overdue queries all read off the same structure.
Preparation
Implement Levels 1–2 with the exact sort keys and verify the numeric-id ordering and case-sensitive substring match.
Model assignments as [start, finish) intervals with a completed flag, then implement active-at-timestamp, quota freeing on completion, and the overdue query.