Loading content...
An operations analytics team needs two workforce metrics per employee from raw task intervals.
Table: Tasks
Each row represents one task interval handled by an employee.
Your objective: For each employee_id, compute:
Important interval rule:
Output requirements:
Supported submission environments:
Tasks:
| task_id | employee_id | start_time | end_time |
|---------|-------------|----------------------|----------------------|
| 1 | 1001 | 2024-05-01 08:00:00 | 2024-05-01 09:00:00 |
| 2 | 1001 | 2024-05-01 08:30:00 | 2024-05-01 10:30:00 |
| 3 | 1001 | 2024-05-01 11:00:00 | 2024-05-01 12:00:00 |
| 4 | 1001 | 2024-05-01 13:00:00 | 2024-05-01 15:30:00 |
| 5 | 1002 | 2024-05-01 09:00:00 | 2024-05-01 10:00:00 |
| 6 | 1002 | 2024-05-01 09:30:00 | 2024-05-01 11:30:00 |
| 7 | 1003 | 2024-05-01 14:00:00 | 2024-05-01 16:00:00 |[
{"employee_id":1001,"total_task_hours":6,"max_concurrent_tasks":2},
{"employee_id":1002,"total_task_hours":2,"max_concurrent_tasks":2},
{"employee_id":1003,"total_task_hours":2,"max_concurrent_tasks":1}
]Employee 1001 has 6 busy hours after overlap deduplication and reaches concurrency 2. Employee 1002 has 2.5 busy hours (floors to 2) with peak concurrency 2. Employee 1003 has a single 2-hour task.
Tasks:
| task_id | employee_id | start_time | end_time |
|---------|-------------|----------------------|----------------------|
| 101 | 2001 | 2024-05-02 08:00:00 | 2024-05-02 09:00:00 |
| 102 | 2001 | 2024-05-02 09:00:00 | 2024-05-02 10:00:00 |
| 103 | 2001 | 2024-05-02 10:00:00 | 2024-05-02 10:30:00 |
| 104 | 2002 | 2024-05-02 12:00:00 | 2024-05-02 13:00:00 |
| 105 | 2002 | 2024-05-02 12:15:00 | 2024-05-02 12:45:00 |
| 106 | 2002 | 2024-05-02 12:30:00 | 2024-05-02 13:30:00 |[
{"employee_id":2001,"total_task_hours":2,"max_concurrent_tasks":1},
{"employee_id":2002,"total_task_hours":1,"max_concurrent_tasks":3}
]Back-to-back intervals for employee 2001 do not overlap under half-open semantics. Employee 2002 reaches a 3-task overlap window from 12:30 to 12:45.
Tasks:
| task_id | employee_id | start_time | end_time |
|---------|-------------|----------------------|----------------------|
| 201 | 3001 | 2024-05-03 00:00:00 | 2024-05-03 08:00:00 |
| 202 | 3001 | 2024-05-03 01:00:00 | 2024-05-03 07:00:00 |
| 203 | 3001 | 2024-05-03 02:00:00 | 2024-05-03 06:00:00 |
| 204 | 3001 | 2024-05-03 03:00:00 | 2024-05-03 05:00:00 |
| 205 | 3002 | 2024-05-03 09:00:00 | 2024-05-03 09:59:00 |[
{"employee_id":3001,"total_task_hours":8,"max_concurrent_tasks":4},
{"employee_id":3002,"total_task_hours":0,"max_concurrent_tasks":1}
]For employee 3001, nested intervals produce 8 busy hours and peak concurrency 4. Employee 3002 has only 59 minutes of busy time, which floors to 0 hours.
Constraints