def process_documents(m: int, queue_time: list[int], processing_time: list[int],
free_at_finish: bool = True) -> tuple[int, int | None]:The round: two Glean phone-screen reports, from November 2025 and October 2026. The first posted the prompt in full and solved it, and was still rejected; the second got the same question, wrote their own tests, and spent most of the time debugging what they call a lot of code. The prompt has two steps, which are the two graded parts here. Two graded parts.
Problem
Documents are indexed through a processing queue. They are queued at different times and processed in parallel by m indexers numbered 0 to m - 1. An indexer processing a document is busy and cannot take another one.
Document i is assigned to indexer i % m if that indexer is not busy. If it is busy, take the next free indexer in increasing order of number, wrapping back round to 0 if needed. If every indexer is busy, the document is dropped.
You have, from the logs:
m: the number of indexers.queue_time: the times the documents are queued, in increasing order.processing_time: how long each document takes to process.Part 1 — documents processed, and the busiest indexer
def process_documents(m: int, queue_time: list[int], processing_time: list[int],
free_at_finish: bool = True) -> tuple[int, int | None]:
Return the total number of documents processed and the indexer that processed the most. Ties go to the lower number; with nothing processed, the indexer is None.
Example (reported)
m = 3, queue_time = [1, 2, 3, 7], processing_time = [5, 4, 3, 2]
Documents processed: 4
Indexer that processed the most: 0
Top 2 indexers: [0, 1] or [0, 2]
Share processed by them: 75%
All four documents are processed: indexers 0, 1 and 2 take documents 0, 1 and 2, and indexer 0, free again at time 6, takes document 3 at time 7.
Clarify before coding
t as free for a document queued at t; free_at_finish=False is the other reading, and one test shows the two giving different counts.[0, 1] or [0, 2]. The reference breaks ties by the lower number, so it returns [0, 1].Notes: the prompt and its example are reported; the prompt's assignment rule reads "indexer i&m", which we read as i % m because the same sentence says a modulo function is used. The function names, return shapes, free_at_finish, the tie-break, the percentage base, k larger than m returning all m indexers, and ValueError for bad input (no indexers, lists of different lengths, timestamps going backwards, negative processing times, negative k) are ours.
Both reports are phone screens. The first candidate recognised the prompt from an earlier report, solved it quickly, and was still rejected; they say they do not know why. The second says the logic is not hard but the code is long, most of the time went to debugging, and the test cases are yours to write; they finished both steps with little time left for extra tests. The prompt's own example is the cheapest test to write first.
What candidates report: The logic is not hard but the code is long; one candidate spent most of the round debugging and had little time left to run their own tests after finishing both steps. Test cases are yours to write. Another candidate recognised the prompt, solved it quickly and was still rejected.
Edge cases to test: The preferred indexer busy, so the next one up takes it; Wrapping round to indexer 0; Every indexer busy, so the document is dropped; An indexer finishing exactly when a document arrives; Ties for the most documents and in the top k; k larger than the number of indexers; No documents at all
Alternative approaches: Scan up to m indexers per document (O(n * m), the reference); A heap of busy indexers by finish time plus a sorted set of free indexer numbers (O(log m) per document when m is large); A size-k heap instead of sorting all indexers for Step 2
Also reported as Document Indexing Parallel Assignment
The round: two Glean phone-screen reports, from November 2025 and October 2026. The first posted the prompt in full and solved it, and was still rejected; the second got the same question, wrote their own tests, and spent most of the time debugging what they call a lot of code. The prompt has two steps, which are the two graded parts here. Two graded parts.
Problem
Documents are indexed through a processing queue. They are queued at different times and processed in parallel by m indexers numbered 0 to m - 1. An indexer processing a document is busy and cannot take another one.
Document i is assigned to indexer i % m if that indexer is not busy. If it is busy, take the next free indexer in increasing order of number, wrapping back round to 0 if needed. If every indexer is busy, the document is dropped.
You have, from the logs:
m: the number of indexers.queue_time: the times the documents are queued, in increasing order.processing_time: how long each document takes to process.Part 1 — documents processed, and the busiest indexer
def process_documents(m: int, queue_time: list[int], processing_time: list[int],
free_at_finish: bool = True) -> tuple[int, int | None]:
Return the total number of documents processed and the indexer that processed the most. Ties go to the lower number; with nothing processed, the indexer is None.
Part 2 — the top k indexers and their share
def top_k_indexers(m: int, queue_time: list[int], processing_time: list[int], k: int,
free_at_finish: bool = True) -> tuple[list[int], float]:
k is a new input. Return the k indexers that processed the most documents, most first, and the percentage (0 to 100) of documents processed by them.
Example (reported)
m = 3, queue_time = [1, 2, 3, 7], processing_time = [5, 4, 3, 2]
Documents processed: 4
Indexer that processed the most: 0
Top 2 indexers: [0, 1] or [0, 2]
Share processed by them: 75%
All four documents are processed: indexers 0, 1 and 2 take documents 0, 1 and 2, and indexer 0, free again at time 6, takes document 3 at time 7.
Clarify before coding
t as free for a document queued at t; free_at_finish=False is the other reading, and one test shows the two giving different counts.[0, 1] or [0, 2]. The reference breaks ties by the lower number, so it returns [0, 1].Notes: the prompt and its example are reported; the prompt's assignment rule reads "indexer i&m", which we read as i % m because the same sentence says a modulo function is used. The function names, return shapes, free_at_finish, the tie-break, the percentage base, k larger than m returning all m indexers, and ValueError for bad input (no indexers, lists of different lengths, timestamps going backwards, negative processing times, negative k) are ours.
| Approach | Notes |
|---|---|
| Scan up to m indexers per document | O(n * m), the reference |
| A heap of busy indexers by finish time plus a sorted set of free indexer numbers | O(log m) per document when m is large |
| A size-k heap instead of sorting all indexers for Step 2 | — |
What candidates report: The logic is not hard but the code is long; one candidate spent most of the round debugging and had little time left to run their own tests after finishing both steps. Test cases are yours to write. Another candidate recognised the prompt, solved it quickly and was still rejected.
Edge cases to test: The preferred indexer busy, so the next one up takes it; Wrapping round to indexer 0; Every indexer busy, so the document is dropped; An indexer finishing exactly when a document arrives; Ties for the most documents and in the top k; k larger than the number of indexers; No documents at all
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 12 Glean questions, refreshed monthly from new candidate reports.