AO
Back

Assign Queued Documents to Parallel Indexers

Also reported as Document Indexing Parallel Assignment

Phone ScreenPhone ScreenLast reported October 2026Low Frequency

Problem Overview

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

  • Is an indexer free at the moment it finishes? The example does not decide it: indexer 0 finishes at 6 and the next document comes at 7. The reference treats an indexer that finishes at time 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.
  • Percentage of what? Here, of the documents processed. In the example every document is processed, so it cannot tell this apart from all queued documents.
  • Ties. The example accepts [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 Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Scan up to m indexers per documentO(n * m), the reference
A heap of busy indexers by finish time plus a sorted set of free indexer numbersO(log m) per document when m is large
A size-k heap instead of sorting all indexers for Step 2—

What Reports Emphasize

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

Practice

Write your own against 11 test cases, or read the worked solution — approach, complexity, and code that runs.
Did this match your interview?

If you have had this round, tell us how close this page was. It is how we keep the pages accurate.

Prepping for Glean with friends?

Send them this page. It is free to read, no account needed.

More Glean Questions

Free preview

Every question in the Glean catalog gets this depth

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.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Glean · Phone Screen · Reported 2× across candidate reports
Is this helpful?