As reported: Microsoft SE-2 (SQL database engine team, Jan 2025), round 3 (hiring manager), coding part: document search — given a list of documents, a prefix search that returns the documents in which the prefix appears. An inverted index and then a Trie were discussed; the Trie was implemented.
You are given docs, a list of documents (document i is docs[i]), and a list of queries, each a prefix. For every query, return the indices of the documents that contain at least one word starting with that prefix, in increasing order.
A word is a maximal run of non-space characters.
Example 1
docs = ["the quick brown fox", "a lazy dog", "quiet quarters for the dog"]
queries = ["qu", "do", "the", "cat", "quick"]
-> [[0,2], [1,2], [0,2], [], [0]]
Example 2
docs = ["apple app", "application", "banana"]
queries = ["app", "apples", "b", "ban", "banana", "bananas"]
-> [[0,1], [], [2], [2], [2], []]
Constraints: 1 ≤ docs.length ≤ 1000; at most 10^5 words in total, each of 1–10 lowercase letters, separated by spaces (documents may be empty or have extra spaces); 1 ≤ queries.length ≤ 2000; queries are 1–10 lowercase letters.
Code runner format: one JSON value per line: docs, queries. Implement searchDocs(docs, queries); the harness prints the list of results.